// Path: src/test/java/org/elasticsearch/api/demo/BaseDemo.java
// public class BaseDemo {
// 
//     protected TransportClient client;
//     protected RestClient restClient ;
// 
//     @Before
//     public void setUp() throws Exception {
//         /**
//          * 这里的连接方式指的是没有安装x-pack插件,如果安装了x-pack则参考{@link XPackBaseDemo}
//          * 1. java客户端的方式是以tcp协议在9300端口上进行通信
//          * 2. http客户端的方式是以http协议在9200端口上进行通信
//          */
//         client = new PreBuiltTransportClient(Settings.EMPTY)
//                 .addTransportAddress(new TransportAddress(InetAddress.getByName("localhost"), 9300));
//         restClient = RestClient.builder(new HttpHost("localhost",9200)).build();
//     }
// 
//     @After
//     public void tearDown() throws Exception {
//         if (client != null ){
//             client.close();
//         }
// 
//         if (restClient != null){
//             restClient.close();
//         }
//     }
// 
//     @Test
//     public void testClientConnection() throws Exception {
//         AnalyzeRequest analyzeRequest = new AnalyzeRequest();
//         analyzeRequest.text("中华人民共和国");
//         ActionFuture<AnalyzeResponse> analyzeResponseActionFuture = client.admin().indices().analyze(analyzeRequest);
//         List<AnalyzeResponse.AnalyzeToken> analyzeTokens =  analyzeResponseActionFuture.actionGet().getTokens();
//         for (AnalyzeResponse.AnalyzeToken analyzeToken  : analyzeTokens){
//             System.out.println(analyzeToken.getTerm());
//         }
//     }
// 
//     @Test
//     public void testRestClientConnection() throws Exception {
//         String method = "GET";
//         String endpoint = "/_analyze";
//         Map<String, String> params = new HashMap<>();
//         params.put("analyzer","standard");
//         params.put("text","中华人民共和国");
//         Response response = restClient.performRequest(method,endpoint,params);
//         System.out.println(JSON.toJSONString(JSONObject.parse(EntityUtils.toString(response.getEntity())), SerializerFeature.PrettyFormat));
//     }
// 
//     protected void println(SearchResponse searchResponse){
//         SearchHit[]  searchHits = searchResponse.getHits().getHits();
//         for (SearchHit searchHit : searchHits){
//             System.out.println(JSON.toJSONString(searchHit.getSourceAsString(),SerializerFeature.PrettyFormat));
//         }
//     }
// 
// }


import org.elasticsearch.api.demo.BaseDemo;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.junit.Test;
package org.elasticsearch.api.demo.compound;


/**
 * @see <a href='https://www.elastic.co/guide/en/elasticsearch/client/java-api/5.5/java-compound-queries.html'></a>
 * @auhthor lei.fang@shijue.me
 * @since . 2017-07-08
 */
public class BoostQueryDemo extends BaseDemo {

    @Test
    public void testForClient() throws Exception {
        QueryBuilder qb = QueryBuilders.boostingQuery(
// Path: src/test/java/org/elasticsearch/api/demo/BaseDemo.java
// public class BaseDemo {
// 
//     protected TransportClient client;
//     protected RestClient restClient ;
// 
//     @Before
//     public void setUp() throws Exception {
//         /**
//          * 这里的连接方式指的是没有安装x-pack插件,如果安装了x-pack则参考{@link XPackBaseDemo}
//          * 1. java客户端的方式是以tcp协议在9300端口上进行通信
//          * 2. http客户端的方式是以http协议在9200端口上进行通信
//          */
//         client = new PreBuiltTransportClient(Settings.EMPTY)
//                 .addTransportAddress(new TransportAddress(InetAddress.getByName("localhost"), 9300));
//         restClient = RestClient.builder(new HttpHost("localhost",9200)).build();
//     }
// 
//     @After
//     public void tearDown() throws Exception {
//         if (client != null ){
//             client.close();
//         }
// 
//         if (restClient != null){
//             restClient.close();
//         }
//     }
// 
//     @Test
//     public void testClientConnection() throws Exception {
//         AnalyzeRequest analyzeRequest = new AnalyzeRequest();
//         analyzeRequest.text("中华人民共和国");
//         ActionFuture<AnalyzeResponse> analyzeResponseActionFuture = client.admin().indices().analyze(analyzeRequest);
//         List<AnalyzeResponse.AnalyzeToken> analyzeTokens =  analyzeResponseActionFuture.actionGet().getTokens();
//         for (AnalyzeResponse.AnalyzeToken analyzeToken  : analyzeTokens){
//             System.out.println(analyzeToken.getTerm());
//         }
//     }
// 
//     @Test
//     public void testRestClientConnection() throws Exception {
//         String method = "GET";
//         String endpoint = "/_analyze";
//         Map<String, String> params = new HashMap<>();
//         params.put("analyzer","standard");
//         params.put("text","中华人民共和国");
//         Response response = restClient.performRequest(method,endpoint,params);
//         System.out.println(JSON.toJSONString(JSONObject.parse(EntityUtils.toString(response.getEntity())), SerializerFeature.PrettyFormat));
//     }
// 
//     protected void println(SearchResponse searchResponse){
//         SearchHit[]  searchHits = searchResponse.getHits().getHits();
//         for (SearchHit searchHit : searchHits){
//             System.out.println(JSON.toJSONString(searchHit.getSourceAsString(),SerializerFeature.PrettyFormat));
//         }
//     }
// 
// }


// Path: src/test/java/org/elasticsearch/api/demo/compound/BoostQueryDemo.java
import org.elasticsearch.api.demo.BaseDemo;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.junit.Test;

package org.elasticsearch.api.demo.compound;


/**
 * @see <a href='https://www.elastic.co/guide/en/elasticsearch/client/java-api/5.5/java-compound-queries.html'></a>
 * @auhthor lei.fang@shijue.me
 * @since . 2017-07-08
 */
public class BoostQueryDemo extends BaseDemo {

    @Test
    public void testForClient() throws Exception {
        QueryBuilder qb = QueryBuilders.boostingQuery(
                QueryBuilders.termQuery("name","kimchy"),