//package com.elab.es.data;
//
//import com.elab.es.model.Posts;
//import org.elasticsearch.action.ActionRequest;
//import org.elasticsearch.client.RestHighLevelClient;
//import org.elasticsearch.client.transport.TransportClient;
//import org.elasticsearch.common.settings.Settings;
//import org.elasticsearch.common.transport.TransportAddress;
//import org.elasticsearch.plugin.nlpcn.QueryActionElasticExecutor;
//import org.elasticsearch.xpack.client.PreBuiltXPackTransportClient;
//import org.junit.Before;
//import org.junit.Test;
//import org.nlpcn.es4sql.SearchDao;
//import org.nlpcn.es4sql.jdbc.ObjectResult;
//import org.nlpcn.es4sql.jdbc.ObjectResultsExtractor;
//import org.nlpcn.es4sql.query.QueryAction;
//import org.zxp.esclientrhl.repository.ElasticsearchTemplateImpl;
//
//import java.net.InetAddress;
//
///**
// * @Module TODO
// * @Description TODO
// * @Author liukaixiong
// * @Date 2021/1/29 15:34
// */
//public class ElasticSearchSQLAPITest {
//
//    private SearchDao searchDao;
//
//    private RestHighLevelClient restHighLevelClient;
//    private ElasticsearchTemplateImpl<Posts, String> elasticsearchTemplate;
//    private TransportClient client;
//
//    @Before
//    public void before() throws Exception {
////        client = new RestHighLevelClient(
////                RestClient.builder(
////                        new HttpHost("localhost", 9200, "http")));
////                        new HttpHost("192.168.0.24", 9200, "http")));
//        String host = "localhost";
//        String port = "9300";
//        TransportAddress transportAddress = new TransportAddress(InetAddress.getByName(host), Integer.parseInt(port));
//        Settings settings = Settings.builder().put("client.transport.ignore_cluster_name", true).build();
//        client = new PreBuiltXPackTransportClient(settings).addTransportAddress(transportAddress);
//        searchDao = new SearchDao(client);
//    }
//
//
//    @Test
//    public void parseSQLSelectTest() throws Exception {
//
//        String sql = "select * from posts where user like '某%'";
//        QueryAction explain = searchDao.explain(sql);
//        ActionRequest request = explain.explain().request();
//        // restHighLevelClient.search(request,null);
////        MultiMatchQueryBuilder multiMatchQueryBuilder = QueryBuilders.multiMatchQuery("", "");
////        MultiMatchQueryBuilder multiMatchQueryBuilder = QueryBuilders.multiMatchQuery("", "");
//        Object execution = QueryActionElasticExecutor.executeAnyAction(searchDao.getClient(), explain);
//        ObjectResult result = (new ObjectResultsExtractor(true, true, true, false, explain)).extractResults(execution, false);
//        System.out.println(result);
//    }
//
//
//}
