package com.elephant.framework.galaxy.aroad.bigdata;

import com.google.gson.Gson;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.transport.client.PreBuiltTransportClient;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.net.InetAddress;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * @Description: 自定义elasticsearch工具类，
 * 1、实现elasticsearch集群的连接
 * 2、路段、桥梁索引数据插入
 * 3、路段、桥梁分词检索
 * 4、分词检索出来的数据是否是路段数据或者桥梁数据
 * @Param:
 * @return:
 * @Author: dongjili
 * @Date:
 */
public class EsUtil_fanshe {
    public static TransportClient transportClient;
    public static Gson gson = new Gson();

    /**
     * @Description: 创建连接
     * @Param:
     * @return: transportClient
     * @Author: dongjili
     * @Date:
     */
    public static TransportClient getClient() throws Exception {
        Settings settings = Settings.builder().put("cluster.name", "myes").build();
        if (transportClient == null) {
            synchronized (EsUtil_fanshe.class) {
                // 创建Client连接对象
                transportClient = new PreBuiltTransportClient(settings)
                        .addTransportAddress(new TransportAddress(InetAddress.getByName("192.168.7.200"), 9300))
                        .addTransportAddress(new TransportAddress(InetAddress.getByName("192.168.7.210"), 9300))
                        .addTransportAddress(new TransportAddress(InetAddress.getByName("192.168.7.220"), 9300));
            }

        }

        return transportClient;
    }

    /**
     * @Description: 释放资源
     * @Param:
     * @return:
     * @Author: dongjili
     * @Date:
     */
    public static void close() {
        //释放资源
        if (transportClient != null) {
            transportClient.close();
        }
    }

    /**
     * @Description: 桥梁所有数据查询
     * @Param:
     * @return:
     * @Author: dongjili
     * @Date: 2019/5/13 0013
     */
    public static List<Basebridgealldata> queryBridgeAll(String index, String type, int start, int row) throws Exception {
        // 搜索数据
        SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(index).setTypes(type).setFrom(start).setSize(row);
        //isNotBlank(str) 等价于 str != null && str.length > 0 && str.trim().length> 0(去掉字符串两端的多余的空格的长度）
        searchRequestBuilder.setQuery(QueryBuilders.matchAllQuery());

        String[] bridgeNames = {
                "id",
                "quhuadaima",
                "quhuamingcheng",
                "qiaoliangmingcheng",
                "qiaoliangdaima",
                "zhongxinzhuanghao",
                "luxianbianma",
                "luxianmingcheng",
                "jishudengji",
                "quanchang",
                "kuajingzongchang",
                "dankongzuidakuajing",
                "qiaoliangquankuan",
                "qiaomianjingkuan",
                "kuajingfenleidaima",
                "kuajingfenleileixing",
                "nianxianfenleidaima",
                "nianxianfenleileixing",
                "yuanshangbujiegou1daima",
                "yuanshangbujiegou1xingshi",
                "yuanshangbujiegou2daima",
                "yuanshangbujiegou2xingshi",
                "shangbujiegoudaima",
                "shangbujiegouxingshi",
                "shangbujiegoucailiaodaima",
                "shangbujiegoucailiaomingcheng",
                "qiaodunleixingdaima",
                "qiaodunleixingmingcheng",
                "shejihezaidaima",
                "shejihezaidengji",
                "kangzhendengjidaima",
                "kangzhendengji",
                "kuayuediwudaima",
                "kuayuediwuleixing",
                "kuayuemingcheng",
                "tonghangdengji",
                "fangzhuangleixing",
                "lijiaoleibie",
                "jianshedanwei",
                "shejidanwei",
                "shigongdanwei",
                "jianlidanwei",
                "xiujianniandu",
                "tongcheriqi",
                "guanyangdaima",
                "guanyangmingcheng",
                "jianguandanweimingcheng",
                "shoufeixingzhidaima",
                "shoufeixingzhi",
                "pingdingdengjidaima",
                "pingdingdengji",
                "pingdingdanwei",
                "pingdingriqi",
                "gaizaoniandu",
                "wangongriqi",
                "gaizaobuwei",
                "gaizaoshigongdanwei",
                "gongchengxingzhi",
                "bubuxiangmu",
                "binghaidaima",
                "binghaibuwei",
                "binghaimiaoshu",
                "guanzhicuoshidaima",
                "guanzhicuoshi",
                "beizhu",
                "zhuqiaokongshu",
                "zhuqiaozhukua",
                "zhuqiaobiankua",
                "qianyinqiaochang",
                "houyinqiaochang",
                "qiaoxiajingkong",
                "xiabujiegoudaima",
                "xiabujiegoumingcheng",
                "qiaotaidaima",
                "qiaotaimingcheng",
                "zhizuodaima",
                "zhizuomingcheng",
                "qiaomianpuzhuangdaima",
                "qiaomianpuzhuangmingcheng",
                "shensuofengdaima",
                "shensuofengmingcheng",
                "wanpoxiedaima",
                "wanpoxiemingcheng",
                "yuyingliqiao",
                "zaixiuzaijian",
                "zhadaomianji",
                "shejihongshuipinlv",
                "zongzaojia",
                "maishezhuanghao",
                "shifouzhadaoqiao",
                "shifoushangkuaqiao",
                "guanlidanweimingcheng",
                "guanlidanweidaima",
                "biangengyuanyindaima",
                "biangengyuanyin",
                "biangengshijian",
                "xiangmuxingzhi",
                "xiangmumingcheng",
                "jihuaxiangmubianma",
                "xiangmuleibie",
                "xiangmudaima",
                "xiangmuluxianbianma",
                "xiangmuluxianmingcheng",
                "xiangmuqiaoliangzhuanghao",
                "xiangmubiangengyuanyin",
                "xiangmubiangengshijian",
                "touzilaiyuan",
                "qiaoliangsuozaiweizhi",
                "shifoukuanluzhaiqiao",
                "shifouzaizhangdaqiaolaingmuluzhong",
                "tianbaodanweimingcheng",
                "shape",
                "qiaokuazuhe"
        };
        SearchResponse response = searchRequestBuilder.get();
        //获取命中次数，查询结果有多少对象
        SearchHits hits = response.getHits();
        ArrayList<Basebridgealldata> basebridgealldataList = new ArrayList<>();
        for (SearchHit hit : hits) {
            //System.out.println(hit.getSourceAsString());
            Map<String, Object> sourceAsMap = hit.getSourceAsMap();
            //LuKeBridge luKeBridge = new LuKeBridge();
            //获取该类在堆区的Class对象
            Class<?> clazz = Class.forName("com.elephant.framework.galaxy.aroad.bigdata.Basebridgealldata");
            //获取私有的构造方法
            Constructor<?> constructor = clazz.getDeclaredConstructor();
            //暴力破解
            constructor.setAccessible(true);
            //实例化对象
            Basebridgealldata basebridgealldata = (Basebridgealldata) constructor.newInstance();
            //获得私有的属性对象
            Field[] beanFiled = clazz.getDeclaredFields();
            basebridgealldata.setId(hit.getId());
            for (int a = 1; a < bridgeNames.length; a++) {
                //暴力破解
                beanFiled[a].setAccessible(true);
                //把查询到的每一个字段的值赋给luKeBridge的每一个属性
                beanFiled[a].set(basebridgealldata, sourceAsMap.get(bridgeNames[a]) == null ? "" : sourceAsMap.get(bridgeNames[a]).toString());
            }
            basebridgealldataList.add(basebridgealldata);
        }
        return basebridgealldataList;
    }

    /**
     * @Description: 桥梁全字段查询
     * @Param:
     * @return:
     * @Author: dongjili
     * @Date:
     */
    public static Map<String, Object> queryBridge(String keyword, String index, String type, int start, int row) throws Exception {
        // 搜索数据
        SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(index).setTypes(type).setFrom(start).setSize(row);
        //isNotBlank(str) 等价于 str != null && str.length > 0 && str.trim().length> 0(去掉字符串两端的多余的空格的长度）
        if (org.apache.commons.lang.StringUtils.isNotBlank(keyword)) {
            //multiMatchQuery多个字段匹配某一个值
            //multiMatchQuery(text,fields)其中的fields是字段的名字，可以写好几个，每一个中间用逗号分隔
            searchRequestBuilder.setQuery(QueryBuilders.multiMatchQuery(keyword,
                    "qiaoliangmingcheng"
            ));
        }
        String[] bridgeNames = {
                "id",
                "quhuadaima",
                "quhuamingcheng",
                "qiaoliangmingcheng",
                "qiaoliangdaima",
                "zhongxinzhuanghao",
                "luxianbianma",
                "luxianmingcheng",
                "jishudengji",
                "quanchang",
                "kuajingzongchang",
                "dankongzuidakuajing",
                "qiaoliangquankuan",
                "qiaomianjingkuan",
                "kuajingfenleidaima",
                "kuajingfenleileixing",
                "nianxianfenleidaima",
                "nianxianfenleileixing",
                "yuanshangbujiegou1daima",
                "yuanshangbujiegou1xingshi",
                "yuanshangbujiegou2daima",
                "yuanshangbujiegou2xingshi",
                "shangbujiegoudaima",
                "shangbujiegouxingshi",
                "shangbujiegoucailiaodaima",
                "shangbujiegoucailiaomingcheng",
                "qiaodunleixingdaima",
                "qiaodunleixingmingcheng",
                "shejihezaidaima",
                "shejihezaidengji",
                "kangzhendengjidaima",
                "kangzhendengji",
                "kuayuediwudaima",
                "kuayuediwuleixing",
                "kuayuemingcheng",
                "tonghangdengji",
                "fangzhuangleixing",
                "lijiaoleibie",
                "jianshedanwei",
                "shejidanwei",
                "shigongdanwei",
                "jianlidanwei",
                "xiujianniandu",
                "tongcheriqi",
                "guanyangdaima",
                "guanyangmingcheng",
                "jianguandanweimingcheng",
                "shoufeixingzhidaima",
                "shoufeixingzhi",
                "pingdingdengjidaima",
                "pingdingdengji",
                "pingdingdanwei",
                "pingdingriqi",
                "gaizaoniandu",
                "wangongriqi",
                "gaizaobuwei",
                "gaizaoshigongdanwei",
                "gongchengxingzhi",
                "bubuxiangmu",
                "binghaidaima",
                "binghaibuwei",
                "binghaimiaoshu",
                "guanzhicuoshidaima",
                "guanzhicuoshi",
                "beizhu",
                "zhuqiaokongshu",
                "zhuqiaozhukua",
                "zhuqiaobiankua",
                "qianyinqiaochang",
                "houyinqiaochang",
                "qiaoxiajingkong",
                "xiabujiegoudaima",
                "xiabujiegoumingcheng",
                "qiaotaidaima",
                "qiaotaimingcheng",
                "zhizuodaima",
                "zhizuomingcheng",
                "qiaomianpuzhuangdaima",
                "qiaomianpuzhuangmingcheng",
                "shensuofengdaima",
                "shensuofengmingcheng",
                "wanpoxiedaima",
                "wanpoxiemingcheng",
                "yuyingliqiao",
                "zaixiuzaijian",
                "zhadaomianji",
                "shejihongshuipinlv",
                "zongzaojia",
                "maishezhuanghao",
                "shifouzhadaoqiao",
                "shifoushangkuaqiao",
                "guanlidanweimingcheng",
                "guanlidanweidaima",
                "biangengyuanyindaima",
                "biangengyuanyin",
                "biangengshijian",
                "xiangmuxingzhi",
                "xiangmumingcheng",
                "jihuaxiangmubianma",
                "xiangmuleibie",
                "xiangmudaima",
                "xiangmuluxianbianma",
                "xiangmuluxianmingcheng",
                "xiangmuqiaoliangzhuanghao",
                "xiangmubiangengyuanyin",
                "xiangmubiangengshijian",
                "touzilaiyuan",
                "qiaoliangsuozaiweizhi",
                "shifoukuanluzhaiqiao",
                "shifouzaizhangdaqiaolaingmuluzhong",
                "tianbaodanweimingcheng",
                "shape",
                "qiaokuazuhe"
        };
        SearchResponse response = searchRequestBuilder.get();
        //获取命中次数，查询结果有多少对象
        SearchHits hits = response.getHits();
        ArrayList<Basebridgealldata> basebridgealldataList = new ArrayList<>();
        for (SearchHit hit : hits) {
            //System.out.println(hit.getSourceAsString());
            Map<String, Object> sourceAsMap = hit.getSourceAsMap();
            //LuKeBridge luKeBridge = new LuKeBridge();
            //获取该类在堆区的Class对象
            Class<?> clazz = Class.forName("com.elephant.framework.galaxy.aroad.bigdata.Basebridgealldata");
            //获取私有的构造方法
            Constructor<?> constructor = clazz.getDeclaredConstructor();
            //暴力破解
            constructor.setAccessible(true);
            //实例化对象
            Basebridgealldata basebridgealldata = (Basebridgealldata) constructor.newInstance();
            //获得私有的属性对象
            Field[] beanFiled = clazz.getDeclaredFields();
            basebridgealldata.setId(hit.getId());
            for (int a = 1; a < bridgeNames.length; a++) {
                //暴力破解
                beanFiled[a].setAccessible(true);
                //把查询到的每一个字段的值赋给luKeBridge的每一个属性
                beanFiled[a].set(basebridgealldata, sourceAsMap.get(bridgeNames[a]) == null ? "" : sourceAsMap.get(bridgeNames[a]).toString());
            }
            basebridgealldataList.add(basebridgealldata);
        }
        return new HashMap<String, Object>() {{
            put("total", hits.getTotalHits());
            put("list", basebridgealldataList);
        }};
    }

    /**
     * @Description: termquery()桥梁代码词条查询
     * @Param:
     * @return:
     * @Author: dongjili
     * @Date: 2019/5/10 0010
     */
    public static ArrayList<Basebridgealldata> queryBridgeQLDM(String keyword, String index, String type, int start, int row) throws Exception {
        // 搜索数据
        SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(index).setTypes(type).setFrom(start).setSize(row);
        //isNotBlank(str) 等价于 str != null && str.length > 0 && str.trim().length> 0(去掉字符串两端的多余的空格的长度）
        if (org.apache.commons.lang.StringUtils.isNotBlank(keyword)) {
            //multiMatchQuery多个字段匹配某一个值
            //multiMatchQuery(text,fields)其中的fields是字段的名字，可以写好几个，每一个中间用逗号分隔
            searchRequestBuilder.setQuery(QueryBuilders.termQuery("qiaoliangdaima", keyword));
        }
        String[] bridgeNames = {
                "id",
                "quhuadaima",
                "quhuamingcheng",
                "qiaoliangmingcheng",
                "qiaoliangdaima",
                "zhongxinzhuanghao",
                "luxianbianma",
                "luxianmingcheng",
                "jishudengji",
                "quanchang",
                "kuajingzongchang",
                "dankongzuidakuajing",
                "qiaoliangquankuan",
                "qiaomianjingkuan",
                "kuajingfenleidaima",
                "kuajingfenleileixing",
                "nianxianfenleidaima",
                "nianxianfenleileixing",
                "yuanshangbujiegou1daima",
                "yuanshangbujiegou1xingshi",
                "yuanshangbujiegou2daima",
                "yuanshangbujiegou2xingshi",
                "shangbujiegoudaima",
                "shangbujiegouxingshi",
                "shangbujiegoucailiaodaima",
                "shangbujiegoucailiaomingcheng",
                "qiaodunleixingdaima",
                "qiaodunleixingmingcheng",
                "shejihezaidaima",
                "shejihezaidengji",
                "kangzhendengjidaima",
                "kangzhendengji",
                "kuayuediwudaima",
                "kuayuediwuleixing",
                "kuayuemingcheng",
                "tonghangdengji",
                "fangzhuangleixing",
                "lijiaoleibie",
                "jianshedanwei",
                "shejidanwei",
                "shigongdanwei",
                "jianlidanwei",
                "xiujianniandu",
                "tongcheriqi",
                "guanyangdaima",
                "guanyangmingcheng",
                "jianguandanweimingcheng",
                "shoufeixingzhidaima",
                "shoufeixingzhi",
                "pingdingdengjidaima",
                "pingdingdengji",
                "pingdingdanwei",
                "pingdingriqi",
                "gaizaoniandu",
                "wangongriqi",
                "gaizaobuwei",
                "gaizaoshigongdanwei",
                "gongchengxingzhi",
                "bubuxiangmu",
                "binghaidaima",
                "binghaibuwei",
                "binghaimiaoshu",
                "guanzhicuoshidaima",
                "guanzhicuoshi",
                "beizhu",
                "zhuqiaokongshu",
                "zhuqiaozhukua",
                "zhuqiaobiankua",
                "qianyinqiaochang",
                "houyinqiaochang",
                "qiaoxiajingkong",
                "xiabujiegoudaima",
                "xiabujiegoumingcheng",
                "qiaotaidaima",
                "qiaotaimingcheng",
                "zhizuodaima",
                "zhizuomingcheng",
                "qiaomianpuzhuangdaima",
                "qiaomianpuzhuangmingcheng",
                "shensuofengdaima",
                "shensuofengmingcheng",
                "wanpoxiedaima",
                "wanpoxiemingcheng",
                "yuyingliqiao",
                "zaixiuzaijian",
                "zhadaomianji",
                "shejihongshuipinlv",
                "zongzaojia",
                "maishezhuanghao",
                "shifouzhadaoqiao",
                "shifoushangkuaqiao",
                "guanlidanweimingcheng",
                "guanlidanweidaima",
                "biangengyuanyindaima",
                "biangengyuanyin",
                "biangengshijian",
                "xiangmuxingzhi",
                "xiangmumingcheng",
                "jihuaxiangmubianma",
                "xiangmuleibie",
                "xiangmudaima",
                "xiangmuluxianbianma",
                "xiangmuluxianmingcheng",
                "xiangmuqiaoliangzhuanghao",
                "xiangmubiangengyuanyin",
                "xiangmubiangengshijian",
                "touzilaiyuan",
                "qiaoliangsuozaiweizhi",
                "shifoukuanluzhaiqiao",
                "shifouzaizhangdaqiaolaingmuluzhong",
                "tianbaodanweimingcheng",
                "shape",
                "qiaokuazuhe"
        };
        SearchResponse response = searchRequestBuilder.get();
        //获取命中次数，查询结果有多少对象
        SearchHits hits = response.getHits();
        ArrayList<Basebridgealldata> basebridgealldataList = new ArrayList<>();
        for (SearchHit hit : hits) {
            //System.out.println(hit.getSourceAsString());
            Map<String, Object> sourceAsMap = hit.getSourceAsMap();
            //LuKeBridge luKeBridge = new LuKeBridge();
            //获取该类在堆区的Class对象
            Class<?> clazz = Class.forName("com.elephant.framework.galaxy.aroad.bigdata.Basebridgealldata");
            //获取私有的构造方法
            Constructor<?> constructor = clazz.getDeclaredConstructor();
            //暴力破解
            constructor.setAccessible(true);
            //实例化对象
            Basebridgealldata basebridgealldata = (Basebridgealldata) constructor.newInstance();
            //获得私有的属性对象
            Field[] beanFiled = clazz.getDeclaredFields();
            basebridgealldata.setId(hit.getId());
            for (int a = 1; a < bridgeNames.length; a++) {
                //暴力破解
                beanFiled[a].setAccessible(true);
                //把查询到的每一个字段的值赋给luKeBridge的每一个属性
                beanFiled[a].set(basebridgealldata, sourceAsMap.get(bridgeNames[a]) == null ? "" : sourceAsMap.get(bridgeNames[a]).toString());
            }
            basebridgealldataList.add(basebridgealldata);
        }
        return basebridgealldataList;
    }

    /**
     * @Description: 桥梁字段查询查询出一条结果就返回
     * @Param:
     * @return:
     * @Author: dongjili
     * @Date:
     */
    public static boolean queryBridgeOne(String keyword, String index, String type, int start, int row) throws Exception {
        // 搜索数据
        SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(index).setTypes(type).setFrom(start).setSize(row);
        //isNotBlank(str) 等价于 str != null && str.length > 0 && str.trim().length> 0(去掉字符串两端的多余的空格的长度）
        if (org.apache.commons.lang.StringUtils.isNotBlank(keyword)) {
            //multiMatchQuery多个字段匹配某一个值
            //multiMatchQuery(text,fields)其中的fields是字段的名字，可以写好几个，每一个中间用逗号分隔
            searchRequestBuilder.setQuery(QueryBuilders.multiMatchQuery(keyword,
                    "id",
                    "qiaoliangmingcheng",
                    "qiaoliangdaima"
            ));
        }
        SearchResponse response = searchRequestBuilder.get();
        //获取命中次数，查询结果有多少对象
        SearchHits hits = response.getHits();
        if (hits.getHits().length > 0) {
            return true;
        } else {
            return false;
        }

    }

    /**
     * @Description: 路段查询所有数据
     * @Param:
     * @return:
     * @Author: dongjili
     * @Date: 2019/5/13 0013
     */
    public static List<Basehighwayalldata> queryHighWayAll(String index, String type, int start, int row) throws Exception {
        //搜索数据
        SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(index).setTypes(type).setFrom(start).setSize(row);
        //isNotBlank(str) 等价于 str != null && str.length > 0 && str.trim().length> 0(去掉字符串两端的多余的空格的长度）

        //multiMatchQuery多个字段匹配某一个值
        //multiMatchQuery(text,fields)其中的fields是字段的名字，可以写好几个，每一个中间用逗号分隔
        searchRequestBuilder.setQuery(QueryBuilders.matchAllQuery());

        String[] highwayNames = {"id",
                "luxianbianhao",
                "quhuadaima",
                "luxianmingcheng",
                "qidianmingcheng",
                "zhidianmingcheng",
                "Qidianzhuanghao",
                "zhidianzhuanghao",
                "licheng",
                "lichengjisuan",
                "sanDlicheng",
                "dengjidaima",
                "dengjimingcheng",
                "chedaodaima",
                "chedaofenlei",
                "mianchengdaima",
                "mianchengfenlei",
                "lujikuandu",
                "lumiankuandu",
                "shejishisu",
                "xiujianniandu",
                "gaijianniandu",
                "chengguanlu",
                "duantoulu",
                "chongfubianma",
                "chongfuxuhao",
                "qidianzhuanghao",
                "zhongdianzhuanghao",
                "yanghulicheng",
                "qingyulicheng",
                "kelvhaolicheng",
                "yilvhualicheng",
                "dimaodaima",
                "dimaohanzi",
                "handongshuliang",
                "maisheqidianzhuanghao",
                "maishezhidianzhuanghao",
                "quhuamingchengshi",
                "quhuamingchengxian",
                "quhuamingchengxiang",
                "luduanxuhao",
                "guanyangdanweileibie",
                "beizhu",
                "kaigongriqi",
                "jungongriqi",
                "qidianfenjiedianleixing",
                "zhidianfenjiedianleixing",
                "shengjichurukou",
                "GBMlicheng",
                "yangbanlicheng",
                "tongcheriqi",
                "luxiandifangmingcheng",
                "jianshexingzhidaima",
                "jianshexingzhihanzi",
                "duanlianleixing",
                "luduanleixingdaima",
                "luduanleixing",
                "guanyangdanweimingcheng",
                "MQI",
                "pingdingdengji",
                "shoufeixingzhi",
                "biangengyuanyindaima",
                "biangengyuanyin",
                "biangengshijian",
                "xiangmuxingzhi",
                "xiangmumingcheng",
                "xiangmudaima",
                "xiangmuqidianmingcheng",
                "xiangmuzhidianmingcheng",
                "xiangmuleibie",
                "jihuaxiangmubianma",
                "xiangmuluxianbianma",
                "xiangmuluxianmingcheng",
                "xiangmubiangengyuanyin",
                "xiangmubiangengshijian",
                "touzilaiyuan",
                "miancenghoudu",
                "zuijinyicidaxiuniandu",
                "zuijinyicizhongxiuniandu",
                "guodaotiaozhengqianluxianbianma",
                "guodaozhuanghaochuandiyuliulicheng",
                "nianpingjunrijiaotongliang",
                "shifouanganxiangongluguanlijieyang",
                "luxiantiaozhengleixing",
                "shangnianluxianbianma",
                "shangnianluxianmingcheng",
                "shangnianluxianqidianzhuanghao",
                "shangnianluxianzhidianzhuanghao",
                "tianbaodanweimingcheng",
                "shape"
        };
        SearchResponse response = searchRequestBuilder.get();
        //获取命中次数，查询结果有多少对象
        SearchHits hits = response.getHits();
        ArrayList<Basehighwayalldata> basehighwayalldataList = new ArrayList<>();
        for (SearchHit hit : hits) {
            Map<String, Object> sourceAsMap = hit.getSourceAsMap();
            //LuKeHighWay luKeHighWay = new LuKeHighWay();
            //获取该类在堆区的Class对象
            Class<?> clazz = Class.forName("com.elephant.framework.galaxy.aroad.bigdata.Basehighwayalldata");
            //获取私有的构造方法
            Constructor<?> constructor = clazz.getDeclaredConstructor();
            //暴力破解
            constructor.setAccessible(true);
            //实例化对象
            Basehighwayalldata basehighwayalldata = (Basehighwayalldata) constructor.newInstance();
            //获取私有的属性字段
            Field[] beanFiled = clazz.getDeclaredFields();
            basehighwayalldata.setId(hit.getId());
            for (int a = 1; a < highwayNames.length; a++) {
                //暴力破解
                beanFiled[a].setAccessible(true);
                //给路段属性复制
                beanFiled[a].set(basehighwayalldata, sourceAsMap.get(highwayNames[a]) == null ? "" : sourceAsMap.get(highwayNames[a]).toString());
            }
            basehighwayalldataList.add(basehighwayalldata);
        }
        return basehighwayalldataList;
    }

    /**
     * @Description: 路段全字段查询
     * @Param:
     * @return:
     * @Author: dongjili
     * @Date:
     */
    public static Map<String, Object>  queryHighWay(String keyword, String index, String type, int start, int row) throws Exception {
        //搜索数据
        SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(index).setTypes(type).setFrom(start).setSize(row);
        //isNotBlank(str) 等价于 str != null && str.length > 0 && str.trim().length> 0(去掉字符串两端的多余的空格的长度）
        if (org.apache.commons.lang.StringUtils.isNotBlank(keyword)) {
            //multiMatchQuery多个字段匹配某一个值
            //multiMatchQuery(text,fields)其中的fields是字段的名字，可以写好几个，每一个中间用逗号分隔
            searchRequestBuilder.setQuery(QueryBuilders.multiMatchQuery(keyword,
                    "luxianbianhao",
                    "luxianmingcheng"
            ));
        }
        String[] highwayNames = {"id",
                "luxianbianhao",
                "quhuadaima",
                "luxianmingcheng",
                "qidianmingcheng",
                "zhidianmingcheng",
                "Qidianzhuanghao",
                "zhidianzhuanghao",
                "licheng",
                "lichengjisuan",
                "sanDlicheng",
                "dengjidaima",
                "dengjimingcheng",
                "chedaodaima",
                "chedaofenlei",
                "mianchengdaima",
                "mianchengfenlei",
                "lujikuandu",
                "lumiankuandu",
                "shejishisu",
                "xiujianniandu",
                "gaijianniandu",
                "chengguanlu",
                "duantoulu",
                "chongfubianma",
                "chongfuxuhao",
                "qidianzhuanghao",
                "zhongdianzhuanghao",
                "yanghulicheng",
                "qingyulicheng",
                "kelvhaolicheng",
                "yilvhualicheng",
                "dimaodaima",
                "dimaohanzi",
                "handongshuliang",
                "maisheqidianzhuanghao",
                "maishezhidianzhuanghao",
                "quhuamingchengshi",
                "quhuamingchengxian",
                "quhuamingchengxiang",
                "luduanxuhao",
                "guanyangdanweileibie",
                "beizhu",
                "kaigongriqi",
                "jungongriqi",
                "qidianfenjiedianleixing",
                "zhidianfenjiedianleixing",
                "shengjichurukou",
                "GBMlicheng",
                "yangbanlicheng",
                "tongcheriqi",
                "luxiandifangmingcheng",
                "jianshexingzhidaima",
                "jianshexingzhihanzi",
                "duanlianleixing",
                "luduanleixingdaima",
                "luduanleixing",
                "guanyangdanweimingcheng",
                "MQI",
                "pingdingdengji",
                "shoufeixingzhi",
                "biangengyuanyindaima",
                "biangengyuanyin",
                "biangengshijian",
                "xiangmuxingzhi",
                "xiangmumingcheng",
                "xiangmudaima",
                "xiangmuqidianmingcheng",
                "xiangmuzhidianmingcheng",
                "xiangmuleibie",
                "jihuaxiangmubianma",
                "xiangmuluxianbianma",
                "xiangmuluxianmingcheng",
                "xiangmubiangengyuanyin",
                "xiangmubiangengshijian",
                "touzilaiyuan",
                "miancenghoudu",
                "zuijinyicidaxiuniandu",
                "zuijinyicizhongxiuniandu",
                "guodaotiaozhengqianluxianbianma",
                "guodaozhuanghaochuandiyuliulicheng",
                "nianpingjunrijiaotongliang",
                "shifouanganxiangongluguanlijieyang",
                "luxiantiaozhengleixing",
                "shangnianluxianbianma",
                "shangnianluxianmingcheng",
                "shangnianluxianqidianzhuanghao",
                "shangnianluxianzhidianzhuanghao",
                "tianbaodanweimingcheng",
                "shape"
        };
        SearchResponse response = searchRequestBuilder.get();
        //获取命中次数，查询结果有多少对象
        SearchHits hits = response.getHits();
        ArrayList<Basehighwayalldata> basehighwayalldataList = new ArrayList<>();
        for (SearchHit hit : hits) {
            Map<String, Object> sourceAsMap = hit.getSourceAsMap();
            //LuKeHighWay luKeHighWay = new LuKeHighWay();
            //获取该类在堆区的Class对象
            Class<?> clazz = Class.forName("com.elephant.framework.galaxy.aroad.bigdata.Basehighwayalldata");
            //获取私有的构造方法
            Constructor<?> constructor = clazz.getDeclaredConstructor();
            //暴力破解
            constructor.setAccessible(true);
            //实例化对象
            Basehighwayalldata basehighwayalldata = (Basehighwayalldata) constructor.newInstance();
            //获取私有的属性字段
            Field[] beanFiled = clazz.getDeclaredFields();
            basehighwayalldata.setId(hit.getId());
            for (int z = 1; z < highwayNames.length; z++) {
                //暴力破解
                //beanFiled[a].setAccessible(true);
                //给路段属性复制
                //beanFiled[a].set(basehighwayalldata, sourceAsMap.get(highwayNames[a]) == null ? "" : sourceAsMap.get(highwayNames[a]).toString());
                try {
                    //强制反射,让private 的属性也可以访问
                    beanFiled[z].setAccessible(true);
                    //把得到的属性进行赋值，就是把读取到的单元格中的数据赋给对应的属性
                       /* Row.MissingCellPolicy RETURN_NULL_AND_BLANK
                        Row.MissingCellPolicy RETURN_BLANK_AS_NULL
                        Row.MissingCellPolicy CREATE_NULL_AS_BLANK*/
                    if (beanFiled[z].getType().equals(String.class)) {
                        beanFiled[z].set(basehighwayalldata, sourceAsMap.get(highwayNames[z]) == null ? "" : sourceAsMap.get(highwayNames[z]).toString());
                    } else if (beanFiled[z].getType().equals(Integer.class)) {
                        beanFiled[z].set(basehighwayalldata, sourceAsMap.get(highwayNames[z]) == null ? 0 : Integer.valueOf(sourceAsMap.get(highwayNames[z]).toString()));
                    } else if (beanFiled[z].getType().equals(Long.class.getName())) {
                        beanFiled[z].set(basehighwayalldata, sourceAsMap.get(highwayNames[z]) == null ? "" : Long.valueOf(sourceAsMap.get(highwayNames[z]).toString()));
                    } else if (beanFiled[z].getType().equals(Float.class)) {
                        beanFiled[z].set(basehighwayalldata, sourceAsMap.get(highwayNames[z]) == null ? "" : Float.valueOf(sourceAsMap.get(highwayNames[z]).toString()));
                    } else if (beanFiled[z].getType().equals(Double.class)) {
                        beanFiled[z].set(basehighwayalldata, sourceAsMap.get(highwayNames[z]) == null ? 0.0 : Double.valueOf(sourceAsMap.get(highwayNames[z]).toString()));
                    } else if (beanFiled[z].getType().equals(Byte.class)) {
                        beanFiled[z].set(basehighwayalldata, sourceAsMap.get(highwayNames[z]) == null ? "" : Byte.valueOf(sourceAsMap.get(highwayNames[z]).toString()));
                    } else if (beanFiled[z].getType().equals(Boolean.class)) {
                        beanFiled[z].set(basehighwayalldata, sourceAsMap.get(highwayNames[z]) == null ? "" : Boolean.valueOf(sourceAsMap.get(highwayNames[z]).toString()));
                    } else if (beanFiled[z].getType().equals(Date.class)) {
                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                        Date date = null;
                        try {
                            date = sdf.parse(sourceAsMap.get(highwayNames[z]) == null ? "" : sourceAsMap.get(highwayNames[z]).toString());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        beanFiled[z].set(basehighwayalldata, date);
                    } else {
                        beanFiled[z].set(basehighwayalldata, sourceAsMap.get(highwayNames[z]) == null ? "" : sourceAsMap.get(highwayNames[z]).toString());
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            basehighwayalldataList.add(basehighwayalldata);
        }
        return new HashMap<String, Object>() {{
            put("total", hits.getTotalHits());
            put("list", basehighwayalldataList);
        }};

    }
    /**
     * @Description: 通过路线编号匹配，查询字段在起点桩号和止点桩号之间范围查询
     * @Param:
     * @return:
     * @Author: dongjili
     * @Date: 2019/5/14 0014
     */
    public static List<Basehighwayalldata> queryHighWayFiler(String lxbh,double zh, String index, String type, int start, int row) throws Exception {
        //搜索数据
        SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(index).setTypes(type).setFrom(start).setSize(row);
        //isNotBlank(str) 等价于 str != null && str.length > 0 && str.trim().length> 0(去掉字符串两端的多余的空格的长度）
        if (org.apache.commons.lang.StringUtils.isNotBlank(lxbh)) {
            //multiMatchQuery多个字段匹配某一个值
            //multiMatchQuery(text,fields)其中的fields是字段的名字，可以写好几个，每一个中间用逗号分隔
            BoolQueryBuilder boolquery = QueryBuilders.boolQuery()
                    .must(QueryBuilders.matchPhraseQuery("luxianbianhao", lxbh))
                    .must(QueryBuilders.rangeQuery("qidianzhuanghaoa").lte(zh))
                    .must(QueryBuilders.rangeQuery("zhidianzhuanghao").gte(zh));
            searchRequestBuilder.setQuery(boolquery);
        }
        String[] highwayNames = {"id",
                "luxianbianhao",
                "quhuadaima",
                "luxianmingcheng",
                "qidianmingcheng",
                "zhidianmingcheng",
                "qidianzhuanghaoa",
                "zhidianzhuanghao",
                "licheng",
                "lichengjisuan",
                "sanDlicheng",
                "dengjidaima",
                "dengjimingcheng",
                "chedaodaima",
                "chedaofenlei",
                "mianchengdaima",
                "mianchengfenlei",
                "lujikuandu",
                "lumiankuandu",
                "shejishisu",
                "xiujianniandu",
                "gaijianniandu",
                "chengguanlu",
                "duantoulu",
                "chongfubianma",
                "chongfuxuhao",
                "qidianzhuanghaob",
                "zhongdianzhuanghao",
                "yanghulicheng",
                "qingyulicheng",
                "kelvhaolicheng",
                "yilvhualicheng",
                "dimaodaima",
                "dimaohanzi",
                "handongshuliang",
                "maisheqidianzhuanghao",
                "maishezhidianzhuanghao",
                "quhuamingchengshi",
                "quhuamingchengxian",
                "quhuamingchengxiang",
                "luduanxuhao",
                "guanyangdanweileibie",
                "beizhu",
                "kaigongriqi",
                "jungongriqi",
                "qidianfenjiedianleixing",
                "zhidianfenjiedianleixing",
                "shengjichurukou",
                "gbmlicheng",
                "yangbanlicheng",
                "tongcheriqi",
                "luxiandifangmingcheng",
                "jianshexingzhidaima",
                "jianshexingzhihanzi",
                "duanlianleixing",
                "luduanleixingdaima",
                "luduanleixing",
                "guanyangdanweimingcheng",
                "mqi",
                "pingdingdengji",
                "shoufeixingzhi",
                "biangengyuanyindaima",
                "biangengyuanyin",
                "biangengshijian",
                "xiangmuxingzhi",
                "xiangmumingcheng",
                "xiangmudaima",
                "xiangmuqidianmingcheng",
                "xiangmuzhidianmingcheng",
                "xiangmuleibie",
                "jihuaxiangmubianma",
                "xiangmuluxianbianma",
                "xiangmuluxianmingcheng",
                "xiangmubiangengyuanyin",
                "xiangmubiangengshijian",
                "touzilaiyuan",
                "miancenghoudu",
                "zuijinyicidaxiuniandu",
                "zuijinyicizhongxiuniandu",
                "guodaotiaozhengqianluxianbianma",
                "guodaozhuanghaochuandiyuliulicheng",
                "nianpingjunrijiaotongliang",
                "shifouanganxiangongluguanlijieyang",
                "luxiantiaozhengleixing",
                "shangnianluxianbianma",
                "shangnianluxianmingcheng",
                "shangnianluxianqidianzhuanghao",
                "shangnianluxianzhidianzhuanghao",
                "tianbaodanweimingcheng",
                "shape"
        };
        SearchResponse response = searchRequestBuilder.get();
        //获取命中次数，查询结果有多少对象
        SearchHits hits = response.getHits();
        List<Basehighwayalldata> basehighwayalldataList = new ArrayList<>();
        for (SearchHit hit : hits) {
            Map<String, Object> sourceAsMap = hit.getSourceAsMap();
            //LuKeHighWay luKeHighWay = new LuKeHighWay();
            //获取该类在堆区的Class对象
            Class<?> clazz = Class.forName("com.elephant.framework.galaxy.aroad.bigdata.Basehighwayalldata");
            //获取私有的构造方法
            Constructor<?> constructor = clazz.getDeclaredConstructor();
            //暴力破解
            constructor.setAccessible(true);
            //实例化对象
            Basehighwayalldata basehighwayalldata = (Basehighwayalldata) constructor.newInstance();
            //获取私有的属性字段
            Field[] beanFiled = clazz.getDeclaredFields();
            basehighwayalldata.setId(hit.getId());
            for (int z = 1; z < highwayNames.length; z++) {
                //暴力破解
                //beanFiled[a].setAccessible(true);
                //给路段属性复制
                //beanFiled[z].set(basehighwayalldata, sourceAsMap.get(highwayNames[z]) == null ? "" : sourceAsMap.get(highwayNames[z]).toString());
                //-----------------------------------------------------------------
                try {
                    //强制反射,让private 的属性也可以访问
                    beanFiled[z].setAccessible(true);
                    //把得到的属性进行赋值，就是把读取到的单元格中的数据赋给对应的属性
                       /* Row.MissingCellPolicy RETURN_NULL_AND_BLANK
                        Row.MissingCellPolicy RETURN_BLANK_AS_NULL
                        Row.MissingCellPolicy CREATE_NULL_AS_BLANK*/
                    if (beanFiled[z].getType().equals(String.class)) {
                        beanFiled[z].set(basehighwayalldata, sourceAsMap.get(highwayNames[z]) == null ? "" : sourceAsMap.get(highwayNames[z]).toString());
                    } else if (beanFiled[z].getType().equals(Integer.class)) {
                        beanFiled[z].set(basehighwayalldata, sourceAsMap.get(highwayNames[z]) == null ? 0 : Integer.valueOf(sourceAsMap.get(highwayNames[z]).toString()));
                    } else if (beanFiled[z].getType().equals(Long.class.getName())) {
                        beanFiled[z].set(basehighwayalldata, sourceAsMap.get(highwayNames[z]) == null ? "" : Long.valueOf(sourceAsMap.get(highwayNames[z]).toString()));
                    } else if (beanFiled[z].getType().equals(Float.class)) {
                        beanFiled[z].set(basehighwayalldata, sourceAsMap.get(highwayNames[z]) == null ? "" : Float.valueOf(sourceAsMap.get(highwayNames[z]).toString()));
                    } else if (beanFiled[z].getType().equals(Double.class)) {
                        beanFiled[z].set(basehighwayalldata, sourceAsMap.get(highwayNames[z]) == null ? 0.0 : Double.valueOf(sourceAsMap.get(highwayNames[z]).toString()));
                    } else if (beanFiled[z].getType().equals(Byte.class)) {
                        beanFiled[z].set(basehighwayalldata, sourceAsMap.get(highwayNames[z]) == null ? "" : Byte.valueOf(sourceAsMap.get(highwayNames[z]).toString()));
                    } else if (beanFiled[z].getType().equals(Boolean.class)) {
                        beanFiled[z].set(basehighwayalldata, sourceAsMap.get(highwayNames[z]) == null ? "" : Boolean.valueOf(sourceAsMap.get(highwayNames[z]).toString()));
                    } else if (beanFiled[z].getType().equals(Date.class)) {
                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                        Date date = null;
                        try {
                            date = sdf.parse(sourceAsMap.get(highwayNames[z]) == null ? "" : sourceAsMap.get(highwayNames[z]).toString());
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        beanFiled[z].set(basehighwayalldata, date);
                    } else {
                        beanFiled[z].set(basehighwayalldata, sourceAsMap.get(highwayNames[z]) == null ? "" : sourceAsMap.get(highwayNames[z]).toString());
                    }

                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            basehighwayalldataList.add(basehighwayalldata);
        }
        return basehighwayalldataList;
    }
    /**
     * @Description: termquery()路线编号词条查询
     * @Param:
     * @return:
     * @Author: dongjili
     * @Date: 2019/5/10 0010
     */
    public static ArrayList<Basehighwayalldata> queryHighWayLXBH(String keyword, String index, String type, int start, int row) throws Exception {
        //搜索数据
        SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(index).setTypes(type).setFrom(start).setSize(row);
        //isNotBlank(str) 等价于 str != null && str.length > 0 && str.trim().length> 0(去掉字符串两端的多余的空格的长度）
        if (org.apache.commons.lang.StringUtils.isNotBlank(keyword)) {
            //multiMatchQuery多个字段匹配某一个值
            //multiMatchQuery(text,fields)其中的fields是字段的名字，可以写好几个，每一个中间用逗号分隔
            searchRequestBuilder.setQuery(QueryBuilders.termQuery("luxianbianhao", keyword));
            /*searchRequestBuilder.setQuery(QueryBuilders.matchQuery("luxianbianhao",keyword));*/
        }
        String[] highwayNames = {"id",
                "luxianbianhao",
                "quhuadaima",
                "luxianmingcheng",
                "qidianmingcheng",
                "zhidianmingcheng",
                "qidianzhuanghaoa",
                "zhidianzhuanghao",
                "licheng",
                "lichengjisuan",
                "sanDlicheng",
                "dengjidaima",
                "dengjimingcheng",
                "chedaodaima",
                "chedaofenlei",
                "mianchengdaima",
                "mianchengfenlei",
                "lujikuandu",
                "lumiankuandu",
                "shejishisu",
                "xiujianniandu",
                "gaijianniandu",
                "chengguanlu",
                "duantoulu",
                "chongfubianma",
                "chongfuxuhao",
                "qidianzhuanghaob",
                "zhongdianzhuanghao",
                "yanghulicheng",
                "qingyulicheng",
                "kelvhaolicheng",
                "yilvhualicheng",
                "dimaodaima",
                "dimaohanzi",
                "handongshuliang",
                "maisheqidianzhuanghao",
                "maishezhidianzhuanghao",
                "quhuamingchengshi",
                "quhuamingchengxian",
                "quhuamingchengxiang",
                "luduanxuhao",
                "guanyangdanweileibie",
                "beizhu",
                "kaigongriqi",
                "jungongriqi",
                "qidianfenjiedianleixing",
                "zhidianfenjiedianleixing",
                "shengjichurukou",
                "gbmlicheng",
                "yangbanlicheng",
                "tongcheriqi",
                "luxiandifangmingcheng",
                "jianshexingzhidaima",
                "jianshexingzhihanzi",
                "duanlianleixing",
                "luduanleixingdaima",
                "luduanleixing",
                "guanyangdanweimingcheng",
                "mqi",
                "pingdingdengji",
                "shoufeixingzhi",
                "biangengyuanyindaima",
                "biangengyuanyin",
                "biangengshijian",
                "xiangmuxingzhi",
                "xiangmumingcheng",
                "xiangmudaima",
                "xiangmuqidianmingcheng",
                "xiangmuzhidianmingcheng",
                "xiangmuleibie",
                "jihuaxiangmubianma",
                "xiangmuluxianbianma",
                "xiangmuluxianmingcheng",
                "xiangmubiangengyuanyin",
                "xiangmubiangengshijian",
                "touzilaiyuan",
                "miancenghoudu",
                "zuijinyicidaxiuniandu",
                "zuijinyicizhongxiuniandu",
                "guodaotiaozhengqianluxianbianma",
                "guodaozhuanghaochuandiyuliulicheng",
                "nianpingjunrijiaotongliang",
                "shifouanganxiangongluguanlijieyang",
                "luxiantiaozhengleixing",
                "shangnianluxianbianma",
                "shangnianluxianmingcheng",
                "shangnianluxianqidianzhuanghao",
                "shangnianluxianzhidianzhuanghao",
                "tianbaodanweimingcheng",
                "shape"
        };
        SearchResponse response = searchRequestBuilder.get();
        //获取命中次数，查询结果有多少对象
        SearchHits hits = response.getHits();
        ArrayList<Basehighwayalldata> basehighwayalldataList = new ArrayList<>();
        for (SearchHit hit : hits) {
            Map<String, Object> sourceAsMap = hit.getSourceAsMap();
            //LuKeHighWay luKeHighWay = new LuKeHighWay();
            //获取该类在堆区的Class对象
            Class<?> clazz = Class.forName("com.elephant.framework.galaxy.aroad.bigdata.Basehighwayalldata");
            //获取私有的构造方法
            Constructor<?> constructor = clazz.getDeclaredConstructor();
            //暴力破解
            constructor.setAccessible(true);
            //实例化对象
            Basehighwayalldata basehighwayalldata = (Basehighwayalldata) constructor.newInstance();
            //获取私有的属性字段
            Field[] beanFiled = clazz.getDeclaredFields();
            basehighwayalldata.setId(hit.getId());
            for (int a = 1; a < highwayNames.length; a++) {
                //暴力破解
                beanFiled[a].setAccessible(true);
                //给路段属性复制
                beanFiled[a].set(basehighwayalldata, sourceAsMap.get(highwayNames[a]) == null ? "" : sourceAsMap.get(highwayNames[a]).toString());
            }
            basehighwayalldataList.add(basehighwayalldata);
        }
        return basehighwayalldataList;
    }

    /**
     * @Description: 路段全字段查询, 查询出一条结果就返回
     * @Param:
     * @return: ArrayList<LuKeHighWay> lukehighways
     * @Author: dongjili
     * @Date:
     */
    public static boolean queryHighWayOne(String keyword, String index, String type, int start, int row) throws Exception {
        //搜索数据
        SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(index).setTypes(type).setFrom(start).setSize(row);
        //isNotBlank(str) 等价于 str != null && str.length > 0 && str.trim().length> 0(去掉字符串两端的多余的空格的长度）
        if (org.apache.commons.lang.StringUtils.isNotBlank(keyword)) {
            //multiMatchQuery多个字段匹配某一个值
            //multiMatchQuery(text,fields)其中的fields是字段的名字，可以写好几个，每一个中间用逗号分隔
            searchRequestBuilder.setQuery(QueryBuilders.multiMatchQuery(keyword,
                    "id",
                    "luxianbianhao",
                    "luxianmingcheng",
                    "qidianmingcheng",
                    "zhidianmingcheng"
            ));
        }
        SearchResponse response = searchRequestBuilder.get();
        //获取命中次数，查询结果有多少对象
        SearchHits hits = response.getHits();
        if (hits.getHits().length > 0) {
            return true;
        } else {
            return false;
        }

    }

    /**
     * @Description: 隧道查询所有数据
     * @Param:
     * @return:
     * @Author: dongjili
     * @Date: 2019/5/13 0013
     */
    public static List<Basetunnelalldata> queryTunnelAll(String index, String type, int start, int row) throws Exception {
        //搜索数据
        SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(index).setTypes(type).setFrom(start).setSize(row);
        //isNotBlank(str) 等价于 str != null && str.length > 0 && str.trim().length> 0(去掉字符串两端的多余的空格的长度）
        //multiMatchQuery多个字段匹配某一个值
        //multiMatchQuery(text,fields)其中的fields是字段的名字，可以写好几个，每一个中间用逗号分隔
        searchRequestBuilder.setQuery(QueryBuilders.matchAllQuery());

        String[] basicTunnelNames = {
                "id",
                "suidaomingcheng",
                "suidaodaima",
                "zhongxinzhuanghao",
                "luxianbianma",
                "luxianmingcheng",
                "jishudengji",
                "changdu",
                "jingkuan",
                "jinggao",
                "changdufenleidaima",
                "fenleimingcheng",
                "shuixiasuidao",
                "xiujianniandu",
                "jianshedanwei",
                "shejidanwei",
                "shigongdanwei",
                "jianlidanwei",
                "tongcheshijian",
                "shuidaoyanghudengji",
                "guanyangdanweixingzhi",
                "guanyangdanweimingcheng",
                "jianguandanwei",
                "pingdingdengji",
                "pingdingriqi",
                "pingdingdanwei",
                "pingdingdengjitujian",
                "pingdingriqitujian",
                "pingdingdanweitujian",
                "pingdingdengjijidian",
                "pingdingriqijidian",
                "pingdingdanweijidian",
                "pingdingdengjiqita",
                "pingdingriqiqita",
                "pingdingdanweiqita",
                "gaijianniandu",
                "wangongriqi",
                "gaizaibuwei",
                "gongchengxingzhi",
                "binghaibuwei",
                "binghaimiaoshu",
                "xianjizhengqudaima",
                "shifouzaizhangdasuidaomuluzhong",
                "beizhu",
                "shape"
        };
        SearchResponse response = searchRequestBuilder.get();
        //获取命中次数，查询结果有多少对象
        SearchHits hits = response.getHits();
        List<Basetunnelalldata> basetunnelalldataList = new ArrayList<>();
        for (SearchHit hit : hits) {
            Map<String, Object> sourceAsMap = hit.getSourceAsMap();
            //LuKeHighWay luKeHighWay = new LuKeHighWay();
            //获取该类在堆区的Class对象
            Class<?> clazz = Class.forName("com.elephant.framework.galaxy.aroad.bigdata.Basetunnelalldata");
            //获取私有的构造方法
            Constructor<?> constructor = clazz.getDeclaredConstructor();
            //暴力破解
            constructor.setAccessible(true);
            //实例化对象
            Basetunnelalldata basetunnelalldata = (Basetunnelalldata) constructor.newInstance();
            //获取私有的属性字段
            Field[] beanFiled = clazz.getDeclaredFields();
            basetunnelalldata.setId(hit.getId());
            for (int a = 1; a < basicTunnelNames.length; a++) {
                //暴力破解
                beanFiled[a].setAccessible(true);
                //给路段属性复制
                beanFiled[a].set(basetunnelalldata, sourceAsMap.get(basicTunnelNames[a]) == null ? "" : sourceAsMap.get(basicTunnelNames[a]).toString());
            }
            basetunnelalldataList.add(basetunnelalldata);
        }
        return basetunnelalldataList;
    }

    /**
     * @Description: 隧道全字段查询
     * @Param:
     * @return:
     * @Author: dongjili
     * @Date: 2019/4/28 0028
     */
    public static HashMap<String, Object> queryTunnel(String keyword, String index, String type, int start, int row) throws Exception {
        //搜索数据
        SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(index).setTypes(type).setFrom(start).setSize(row);
        //isNotBlank(str) 等价于 str != null && str.length > 0 && str.trim().length> 0(去掉字符串两端的多余的空格的长度）
        if (org.apache.commons.lang.StringUtils.isNotBlank(keyword)) {
            //multiMatchQuery多个字段匹配某一个值
            //multiMatchQuery(text,fields)其中的fields是字段的名字，可以写好几个，每一个中间用逗号分隔
            searchRequestBuilder.setQuery(QueryBuilders.multiMatchQuery(keyword,
                    "suidaomingcheng"
            ));
        }
        String[] basicTunnelNames = {
                "id",
                "suidaomingcheng",
                "suidaodaima",
                "zhongxinzhuanghao",
                "luxianbianma",
                "luxianmingcheng",
                "jishudengji",
                "changdu",
                "jingkuan",
                "jinggao",
                "changdufenleidaima",
                "fenleimingcheng",
                "shuixiasuidao",
                "xiujianniandu",
                "jianshedanwei",
                "shejidanwei",
                "shigongdanwei",
                "jianlidanwei",
                "tongcheshijian",
                "shuidaoyanghudengji",
                "guanyangdanweixingzhi",
                "guanyangdanweimingcheng",
                "jianguandanwei",
                "pingdingdengji",
                "pingdingriqi",
                "pingdingdanwei",
                "pingdingdengjitujian",
                "pingdingriqitujian",
                "pingdingdanweitujian",
                "pingdingdengjijidian",
                "pingdingriqijidian",
                "pingdingdanweijidian",
                "pingdingdengjiqita",
                "pingdingriqiqita",
                "pingdingdanweiqita",
                "gaijianniandu",
                "wangongriqi",
                "gaizaibuwei",
                "gongchengxingzhi",
                "binghaibuwei",
                "binghaimiaoshu",
                "xianjizhengqudaima",
                "shifouzaizhangdasuidaomuluzhong",
                "beizhu",
                "shape"
        };
        SearchResponse response = searchRequestBuilder.get();
        //获取命中次数，查询结果有多少对象
        SearchHits hits = response.getHits();
        List<Basetunnelalldata> basetunnelalldataList = new ArrayList<>();
        for (SearchHit hit : hits) {
            Map<String, Object> sourceAsMap = hit.getSourceAsMap();
            //LuKeHighWay luKeHighWay = new LuKeHighWay();
            //获取该类在堆区的Class对象
            Class<?> clazz = Class.forName("com.elephant.framework.galaxy.aroad.bigdata.Basetunnelalldata");
            //获取私有的构造方法
            Constructor<?> constructor = clazz.getDeclaredConstructor();
            //暴力破解
            constructor.setAccessible(true);
            //实例化对象
            Basetunnelalldata basetunnelalldata = (Basetunnelalldata) constructor.newInstance();
            //获取私有的属性字段
            Field[] beanFiled = clazz.getDeclaredFields();
            basetunnelalldata.setId(hit.getId());
            for (int a = 1; a < basicTunnelNames.length; a++) {
                //暴力破解
                beanFiled[a].setAccessible(true);
                //给路段属性复制
                beanFiled[a].set(basetunnelalldata, sourceAsMap.get(basicTunnelNames[a]) == null ? "" : sourceAsMap.get(basicTunnelNames[a]).toString());
            }
            basetunnelalldataList.add(basetunnelalldata);
        }
        return new HashMap<String, Object>() {{
            put("total", hits.getTotalHits());
            put("list", basetunnelalldataList);
        }};
    }

    /**
     * @Description: termquery()隧道代码词条匹配查询
     * @Param:
     * @return:
     * @Author: dongjili
     * @Date: 2019/5/10 0010
     */
    public static List<Basetunnelalldata> queryTunnelSDDM(String keyword, String index, String type, int start, int row) throws Exception {
        //搜索数据
        SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(index).setTypes(type).setFrom(start).setSize(row);
        //isNotBlank(str) 等价于 str != null && str.length > 0 && str.trim().length> 0(去掉字符串两端的多余的空格的长度）
        if (org.apache.commons.lang.StringUtils.isNotBlank(keyword)) {
            //multiMatchQuery多个字段匹配某一个值
            //multiMatchQuery(text,fields)其中的fields是字段的名字，可以写好几个，每一个中间用逗号分隔
            searchRequestBuilder.setQuery(QueryBuilders.termQuery("suidaodaima", keyword));
        }
        String[] basicTunnelNames = {
                "id",
                "suidaomingcheng",
                "suidaodaima",
                "zhongxinzhuanghao",
                "luxianbianma",
                "luxianmingcheng",
                "jishudengji",
                "changdu",
                "jingkuan",
                "jinggao",
                "changdufenleidaima",
                "fenleimingcheng",
                "shuixiasuidao",
                "xiujianniandu",
                "jianshedanwei",
                "shejidanwei",
                "shigongdanwei",
                "jianlidanwei",
                "tongcheshijian",
                "shuidaoyanghudengji",
                "guanyangdanweixingzhi",
                "guanyangdanweimingcheng",
                "jianguandanwei",
                "pingdingdengji",
                "pingdingriqi",
                "pingdingdanwei",
                "pingdingdengjitujian",
                "pingdingriqitujian",
                "pingdingdanweitujian",
                "pingdingdengjijidian",
                "pingdingriqijidian",
                "pingdingdanweijidian",
                "pingdingdengjiqita",
                "pingdingriqiqita",
                "pingdingdanweiqita",
                "gaijianniandu",
                "wangongriqi",
                "gaizaibuwei",
                "gongchengxingzhi",
                "binghaibuwei",
                "binghaimiaoshu",
                "xianjizhengqudaima",
                "shifouzaizhangdasuidaomuluzhong",
                "beizhu",
                "shape"
        };
        SearchResponse response = searchRequestBuilder.get();
        //获取命中次数，查询结果有多少对象
        SearchHits hits = response.getHits();
        List<Basetunnelalldata> basetunnelalldataList = new ArrayList<>();
        for (SearchHit hit : hits) {
            Map<String, Object> sourceAsMap = hit.getSourceAsMap();
            //LuKeHighWay luKeHighWay = new LuKeHighWay();
            //获取该类在堆区的Class对象
            Class<?> clazz = Class.forName("com.elephant.framework.galaxy.aroad.bigdata.Basetunnelalldata");
            //获取私有的构造方法
            Constructor<?> constructor = clazz.getDeclaredConstructor();
            //暴力破解
            constructor.setAccessible(true);
            //实例化对象
            Basetunnelalldata basetunnelalldata = (Basetunnelalldata) constructor.newInstance();
            //获取私有的属性字段
            Field[] beanFiled = clazz.getDeclaredFields();
            basetunnelalldata.setId(hit.getId());
            for (int a = 1; a < basicTunnelNames.length; a++) {
                //暴力破解
                beanFiled[a].setAccessible(true);
                //给路段属性复制
                beanFiled[a].set(basetunnelalldata, sourceAsMap.get(basicTunnelNames[a]) == null ? "" : sourceAsMap.get(basicTunnelNames[a]).toString());
            }
            basetunnelalldataList.add(basetunnelalldata);
        }
        return basetunnelalldataList;
    }

    /**
     * @Description: 隧道全字段查询，查询出一条就返回
     * @Param:
     * @return:
     * @Author: dongjili
     * @Date: 2019/4/28 0028
     */
    public static boolean queryTunnelOne(String keyword, String index, String type, int start, int row) throws Exception {
        //搜索数据
        SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(index).setTypes(type).setFrom(start).setSize(row);
        //isNotBlank(str) 等价于 str != null && str.length > 0 && str.trim().length> 0(去掉字符串两端的多余的空格的长度）
        if (org.apache.commons.lang.StringUtils.isNotBlank(keyword)) {
            //multiMatchQuery多个字段匹配某一个值
            //multiMatchQuery(text,fields)其中的fields是字段的名字，可以写好几个，每一个中间用逗号分隔
            searchRequestBuilder.setQuery(QueryBuilders.multiMatchQuery(keyword,
                    "suidaomingcheng"
            ));
        }
        SearchResponse response = searchRequestBuilder.get();
        //获取命中次数，查询结果有多少对象
        SearchHits hits = response.getHits();
        if (hits.getHits().length > 0) {
            return true;
        } else {
            return false;
        }

    }

    /**
     * @Description: 收费站查询所有数据
     * @Param:
     * @return:
     * @Author: dongjili
     * @Date: 2019/5/13 0013
     */
    public static List<BaseRoadToll_String> queryBaseRoadTollStringAll(String index, String type, int start, int row) throws Exception {
        //搜索数据
        SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(index).setTypes(type).setFrom(start).setSize(row);
        searchRequestBuilder.setQuery(QueryBuilders.matchAllQuery());
        String[] baseRoadTollNames = {"id",
                "roadCode",
                "roadName",
                "number",
                "code",
                "name",
                "shortName",
                "tecLevel",
                "locationType",
                "tollDirection",
                "entNum",
                "entEtcNum",
                "entMtcNum",
                "entMixNum",
                "expNum",
                "expEtcNum",
                "expMtcNum",
                "expMixNum",
                "managementUnit",
                "longitude",
                "latitude"
        };
        SearchResponse response = searchRequestBuilder.get();
        //获取命中次数，查询结果有多少对象
        SearchHits hits = response.getHits();
        ArrayList<BaseRoadToll_String> baseRoadTollStrings = new ArrayList<>();
        for (SearchHit hit : hits) {
            Map<String, Object> sourceAsMap = hit.getSourceAsMap();
            //LuKeHighWay luKeHighWay = new LuKeHighWay();
            //获取该类在堆区的Class对象
            Class<?> clazz = Class.forName("com.elephant.framework.galaxy.aroad.bigdata.BaseRoadToll_String");
            //获取私有的构造方法
            Constructor<?> constructor = clazz.getDeclaredConstructor();
            //暴力破解
            constructor.setAccessible(true);
            //实例化对象
            BaseRoadToll_String baseRoadTollString = (BaseRoadToll_String) constructor.newInstance();
            //获取私有的属性字段
            Field[] beanFiled = clazz.getDeclaredFields();
            baseRoadTollString.setId(hit.getId());
            for (int a = 1; a < baseRoadTollNames.length; a++) {
                //暴力破解
                beanFiled[a].setAccessible(true);
                //给路段属性复制
                beanFiled[a].set(baseRoadTollString, sourceAsMap.get(baseRoadTollNames[a]) == null ? "" : sourceAsMap.get(baseRoadTollNames[a]).toString());
            }
            baseRoadTollStrings.add(baseRoadTollString);

        }
        return baseRoadTollStrings;
    }

    /**
     * @Description: 收费站全字段查询
     * @Param:
     * @return:
     * @Author: dongjili
     * @Date: 2019/4/28 0028
     */
    public static HashMap<String, Object> queryBaseRoadTollString(String keyword, String index, String type, int start, int row) throws Exception {
        //搜索数据
        SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(index).setTypes(type).setFrom(start).setSize(row);
        //isNotBlank(str) 等价于 str != null && str.length > 0 && str.trim().length> 0(去掉字符串两端的多余的空格的长度）
        if (org.apache.commons.lang.StringUtils.isNotBlank(keyword)) {
            //multiMatchQuery多个字段匹配某一个值
            //multiMatchQuery(text,fields)其中的fields是字段的名字，可以写好几个，每一个中间用逗号分隔
            searchRequestBuilder.setQuery(QueryBuilders.multiMatchQuery(keyword,
                    "name"
            ));
        }
        String[] baseRoadTollNames = {"id",
                "roadCode",
                "roadName",
                "number",
                "code",
                "name",
                "shortName",
                "tecLevel",
                "locationType",
                "tollDirection",
                "entNum",
                "entEtcNum",
                "entMtcNum",
                "entMixNum",
                "expNum",
                "expEtcNum",
                "expMtcNum",
                "expMixNum",
                "managementUnit",
                "longitude",
                "latitude"
        };
        SearchResponse response = searchRequestBuilder.get();
        //获取命中次数，查询结果有多少对象
        SearchHits hits = response.getHits();
        ArrayList<BaseRoadToll_String> baseRoadTollStrings = new ArrayList<>();
        for (SearchHit hit : hits) {
            Map<String, Object> sourceAsMap = hit.getSourceAsMap();
            //LuKeHighWay luKeHighWay = new LuKeHighWay();
            //获取该类在堆区的Class对象
            Class<?> clazz = Class.forName("com.elephant.framework.galaxy.aroad.bigdata.BaseRoadToll_String");
            //获取私有的构造方法
            Constructor<?> constructor = clazz.getDeclaredConstructor();
            //暴力破解
            constructor.setAccessible(true);
            //实例化对象
            BaseRoadToll_String baseRoadTollString = (BaseRoadToll_String) constructor.newInstance();
            //获取私有的属性字段
            Field[] beanFiled = clazz.getDeclaredFields();
            baseRoadTollString.setId(hit.getId());
            for (int a = 1; a < baseRoadTollNames.length; a++) {
                //暴力破解
                beanFiled[a].setAccessible(true);
                //给路段属性复制
                beanFiled[a].set(baseRoadTollString, sourceAsMap.get(baseRoadTollNames[a]) == null ? "" : sourceAsMap.get(baseRoadTollNames[a]).toString());
            }
            baseRoadTollStrings.add(baseRoadTollString);

        }
        return new HashMap<String, Object>() {{
            put("total", hits.getTotalHits());
            put("list", baseRoadTollStrings);
        }};
    }

    /**
     * @Description: 收费站全字段查询，查询出一条数据就返回
     * @Param:
     * @return:
     * @Author: dongjili
     * @Date: 2019/4/28 0028
     */
    public static boolean queryBaseRoadTollOne(String keyword, String index, String type, int start, int row) throws Exception {
        //搜索数据
        SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(index).setTypes(type).setFrom(start).setSize(row);
        //isNotBlank(str) 等价于 str != null && str.length > 0 && str.trim().length> 0(去掉字符串两端的多余的空格的长度）
        if (org.apache.commons.lang.StringUtils.isNotBlank(keyword)) {
            //multiMatchQuery多个字段匹配某一个值
            //multiMatchQuery(text,fields)其中的fields是字段的名字，可以写好几个，每一个中间用逗号分隔
            searchRequestBuilder.setQuery(QueryBuilders.multiMatchQuery(keyword,
                    "name"
            ));
        }
        SearchResponse response = searchRequestBuilder.get();
        //获取命中次数，查询结果有多少对象
        SearchHits hits = response.getHits();
        if (hits.getHits().length > 0) {
            return true;
        } else {
            return false;
        }

    }

    /**
     * @Description: 查询服务区所有数据
     * @Param:
     * @return:
     * @Author: dongjili
     * @Date: 2019/5/13 0013
     */
    public static List<BaseHighWayService> queryBaseHighWayServiceAll(String index, String type, int start, int row) throws Exception {
        //搜索数据
        SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(index).setTypes(type).setFrom(start).setSize(row);
        searchRequestBuilder.setQuery(QueryBuilders.matchAllQuery());
        String[] baseRoadTollNames = {
                "id",
                "lxbh",
                "lxmc",
                "zh1",
                "fwsslx",
                "fwssmc",
                "csyysj",
                "bjxs",
                "jyms",
                "zdmj",
                "tccmj",
                "tcwsl",
                "fwssgnSFycs",
                "fwssgnSfyjyss",
                "fwssgnSfyjqss",
                "fwssgnSfyclcdss",
                "fwssgnSfycyss",
                "fwssgnSfycs",
                "fwssgnSfyzsss",
                "fwssgnSfyqcwx",
                "bz",
                "lxbm",
                "zh",
                "jd",
                "wd"
        };
        SearchResponse response = searchRequestBuilder.get();
        //获取命中次数，查询结果有多少对象
        SearchHits hits = response.getHits();
        ArrayList<BaseHighWayService> baseHighWayServices = new ArrayList<>();
        for (SearchHit hit : hits) {
            Map<String, Object> sourceAsMap = hit.getSourceAsMap();
            //LuKeHighWay luKeHighWay = new LuKeHighWay();
            //获取该类在堆区的Class对象
            Class<?> clazz = Class.forName("com.elephant.framework.galaxy.aroad.bigdata.BaseHighWayService");
            //获取私有的构造方法
            Constructor<?> constructor = clazz.getDeclaredConstructor();
            //暴力破解
            constructor.setAccessible(true);
            //实例化对象
            BaseHighWayService baseHighWayService = (BaseHighWayService) constructor.newInstance();
            //获取私有的属性字段
            Field[] beanFiled = clazz.getDeclaredFields();
            baseHighWayService.setId(hit.getId());
            for (int a = 1; a < baseRoadTollNames.length; a++) {
                //暴力破解
                beanFiled[a].setAccessible(true);
                //给路段属性复制
                beanFiled[a].set(baseHighWayService, sourceAsMap.get(baseRoadTollNames[a]) == null ? "" : sourceAsMap.get(baseRoadTollNames[a]).toString());
            }
            baseHighWayServices.add(baseHighWayService);

        }
        return baseHighWayServices;
    }

    /**
     * @Description: 服务区全字段查询
     * @Param:
     * @return:
     * @Author: dongjili
     * @Date: 2019/5/8 0008
     */
    public static HashMap<String, Object> queryBaseHighWayService(String keyword, String index, String type, int start, int row) throws Exception {
        //搜索数据
        SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(index).setTypes(type).setFrom(start).setSize(row);
        //isNotBlank(str) 等价于 str != null && str.length > 0 && str.trim().length> 0(去掉字符串两端的多余的空格的长度）
        if (org.apache.commons.lang.StringUtils.isNotBlank(keyword)) {
            //multiMatchQuery多个字段匹配某一个值
            //multiMatchQuery(text,fields)其中的fields是字段的名字，可以写好几个，每一个中间用逗号分隔
            searchRequestBuilder.setQuery(QueryBuilders.multiMatchQuery(keyword,
                    "fwssmc"
            ));
        }
        String[] baseRoadTollNames = {
                "id",
                "lxbh",
                "lxmc",
                "zh1",
                "fwsslx",
                "fwssmc",
                "csyysj",
                "bjxs",
                "jyms",
                "zdmj",
                "tccmj",
                "tcwsl",
                "fwssgnSFycs",
                "fwssgnSfyjyss",
                "fwssgnSfyjqss",
                "fwssgnSfyclcdss",
                "fwssgnSfycyss",
                "fwssgnSfycs",
                "fwssgnSfyzsss",
                "fwssgnSfyqcwx",
                "bz",
                "lxbm",
                "zh",
                "jd",
                "wd"
        };
        SearchResponse response = searchRequestBuilder.get();
        //获取命中次数，查询结果有多少对象
        SearchHits hits = response.getHits();
        ArrayList<BaseHighWayService> baseHighWayServices = new ArrayList<>();
        for (SearchHit hit : hits) {
            Map<String, Object> sourceAsMap = hit.getSourceAsMap();
            //LuKeHighWay luKeHighWay = new LuKeHighWay();
            //获取该类在堆区的Class对象
            Class<?> clazz = Class.forName("com.elephant.framework.galaxy.aroad.bigdata.BaseHighWayService");
            //获取私有的构造方法
            Constructor<?> constructor = clazz.getDeclaredConstructor();
            //暴力破解
            constructor.setAccessible(true);
            //实例化对象
            BaseHighWayService baseHighWayService = (BaseHighWayService) constructor.newInstance();
            //获取私有的属性字段
            Field[] beanFiled = clazz.getDeclaredFields();
            baseHighWayService.setId(hit.getId());
            for (int a = 1; a < baseRoadTollNames.length; a++) {
                //暴力破解
                beanFiled[a].setAccessible(true);
                //给路段属性复制
                beanFiled[a].set(baseHighWayService, sourceAsMap.get(baseRoadTollNames[a]) == null ? "" : sourceAsMap.get(baseRoadTollNames[a]).toString());
            }
            baseHighWayServices.add(baseHighWayService);

        }
        return new HashMap<String, Object>() {{
            put("total", hits.getTotalHits());
            put("list", baseHighWayServices);
        }};
    }

    /**
     * @Description: 服务区全字段查询，查询出一条数据就返回
     * @Param:
     * @return:
     * @Author: dongjili
     * @Date: 2019/5/8 0008
     */
    public static boolean queryBaseHighWayServiceOne(String keyword, String index, String type, int start, int row) throws Exception {
        //搜索数据
        SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(index).setTypes(type).setFrom(start).setSize(row);
        //isNotBlank(str) 等价于 str != null && str.length > 0 && str.trim().length> 0(去掉字符串两端的多余的空格的长度）
        if (org.apache.commons.lang.StringUtils.isNotBlank(keyword)) {
            //multiMatchQuery多个字段匹配某一个值
            //multiMatchQuery(text,fields)其中的fields是字段的名字，可以写好几个，每一个中间用逗号分隔
            searchRequestBuilder.setQuery(QueryBuilders.multiMatchQuery(keyword,
                    "fwssmc"
            ));
        }
        SearchResponse response = searchRequestBuilder.get();
        //获取命中次数，查询结果有多少对象
        SearchHits hits = response.getHits();
        if (hits.getHits().length > 0) {
            return true;
        } else {
            return false;
        }
    }
}

