使用 dmesg 来查看一些硬件或驱动程序的信息或问题。

相同的查询条件返回的结果数目不同

Elasticsearch | 作者 ydj | 发布于2017年08月24日 | 阅读数:3839

现在有es集群,3台服务器,发现相同的查询条件,返回的结果不同
ip1:9200和ip2:9200返回结果正确,ip3:9200返回结果缺失
ip1和ip2的结果如下:
{
   "took": 3,
   "timed_out": false,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   },
   "hits": {
      "total": 7,
      "max_score": null,
      "hits": [
         {
    ......
 
ip3的结果如下:
{
   "took": 1,
   "timed_out": false,
   "_shards": {
      "total": 5,
      "successful": 3,
      "failed": 0
   },
   "hits": {
      "total": 3,
      "max_score": null,
      "hits": [
         {
     ......
 
client初始化方式:
 Settings settings = Settings.builder()
                .put("cluster.name", config.getEsClusterName())
                .put("client.transport.sniff", true)
                .put("client.transport.ping_timeout", "60s").build();
        try {
            client = new PreBuiltTransportClient(settings);
            String[] ips = config.getEsClusterIp().split(",");
            for (String ip : ips) {
                client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(ip), Integer.valueOf(config.getEsClusterPort())));
            }
查询方式:
SearchRequestBuilder requestBuilder = client.prepareSearch(config.getIndex()).setTypes(config.getType())
                .setPreference("_primary")
                .setQuery(boolQueryBuilder)
                .setFrom(Integer.valueOf(startIndex))
                .setSize(Integer.valueOf(pageSize))
                .addSort(sortBuilder);
 
哪位大神指点一下,困扰我很久了,非常感谢!
已邀请:

Cheetah

赞同来自:

你发的图里已经很清楚了啊,ip1,ip2,完好分片是5,ip3完好分片是3,当然结果会不一样,重启ip3,因为你指定查询的主分片,那么这里出现这个问题,最大的可能是ip3已经和某个ip通信失败

要回复问题请先登录注册