Elasticsearch返回总数624,但命中数组为空

0qx6xfy6  于 12个月前  发布在  ElasticSearch
关注(0)|答案(4)|浏览(89)

我有一个奇怪的查询结果:它共返回了612份文件,但没有匹配结果。
这是查询:

{
  "from": 900,
  "size": 30,
  "query": {
    "filtered": {
      "filter": {
        "bool": {
          "must": [
            {
              "term": {
                "user_id": "145698489"
              }
            }
          ],
          "should": [
            {
              "bool": {
                "must": [
                  {
                    "range": {
                      "date_created": {
                        "to": "2016-07-30T20:11:09.176-03:00",
                        "gte": "2016-07-07T23:39:45.530-03:00"
                      }
                    }
                  }
                ],
                "must_not": [
                  {
                    "term": {
                      "resource.object.label": "hidden"
                    }
                  }
                ],
                "should": []
              }
            }
          ]
        }
      }
    }
  }
}

这就是结果:

{
    "_shards": {
        "failed": 0,
        "successful": 1,
        "total": 1
    },
    "hits": {
        "hits": [],
        "max_score": 1,
        "total": 612
    },
    "timed_out": false,
    "took": 73
}

但是如果我改变日期范围,我会得到正确的结果。
为什么ES要这么做?

wb1gzix0

wb1gzix01#

因为你把from设为900。如果你有少于900点击它不会返回命中。

yc0p9oo0

yc0p9oo02#

在我的情况下,这发生了,因为我设置的限制为零,哈哈。

atmip9wb

atmip9wb3#

您应该尝试从www.example.com设置0.in您的查询。同样重要的是要知道,最近ES处理滚动的方式发生了一些变化。因此,你应该把scrol放在哪里很重要,试着把一个next_scroll = results['_scroll_id']设置在while循环之外,另一个scroll next_scroll = results['_scroll_id']设置在while循环代码行的末尾。在我改变了滚动点后,它对我很有效。

toiithl6

toiithl64#

我们也遇到了这个问题,为了解决这个问题,我们需要从_source中删除excludes cluase。

_source: {
  excludes: %w{embedding score tags}
},

相关问题