简体   繁体   English

Elasticsearch:空的命中数组,尽管总数大于0

[英]Elasticsearch: empty hits array although total is greater than 0

For the following query 对于以下查询

    {
        index: i,
        from: 0,
        size: 10,
        body: {
            query: {
                filtered: {
                    query: {
                        term: { "si" : si}
                    }
                }                       
            }
        }               
    }

I get returned the following answer 我得到了以下答案

    {
      "took": 1,
      "timed_out": false,
      "_shards": {
        "total": 1,
        "successful": 1,
        "failed": 0
      },
      "hits": {
        "total": 4,
        "max_score": 5.1108737,
        "hits": [

        ]
      }
    }

I found this post on the same topic https://discuss.elastic.co/t/hits-hits-array-empty-even-thought-total-1/19930 but still don't understand, how to solve my problem, since I thought 我在同一主题https://discuss.elastic.co/t/hits-hits-array-empty-even-thought-total-1/19930中找到了该帖子,但仍然不明白如何解决我的问题,自从我以为

from: 1

would according to his solution solve the issue. 会根据他的解决方案解决问题。

Thanks for your help 谢谢你的帮助

By default, elasticsearch starts showing its  Query results from pageNum as 0 and the search query we define generally start from pageNum as 1.
Ensure that if you are setting the pageNum, it is set to 0 in case you have the resultset within the pageSize limit.

I was facing the same issue where I could see total_hits as 1 with empty array being returned. 我面临着同样的问题,我可以将total_hits视为1并返回空数组。 I found that I was setting the default pageNum to 1 ,however elasticsearch starts it from 0 and hence was returning the second page when queried with pageNum as 1 我发现我将默认的pageNum设置为1,但是elasticsearch从0开始,因此在将pageNum设为1时返回第二页。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Elasticsearch 返回大于指定范围的结果 - Elasticsearch returns results greater than specified in range nodejs - 值差大于 2 的单独数组 - nodejs - separate array with value difference greater than 2 为什么使用AWS SDK for JavaScript在S3存储桶文件夹中列出对象会返回空内容数组,但KeyCount大于1? - Why does listing objects in an S3 bucket's folder using AWS SDK for JavaScript returns empty Contents array but KeyCount greater than one? Mongodb 查找数组长度大于指定大小 - Mongodb find array length greater than specified size 如何在MongoDB中找到大于文档大小的数组 - How to find array greater than document size in MongoDB 查询所有数组项均大于指定条件的位置 - Query where all array items are greater than a specified condition 如何在mongodb中查找数组大小大于1的文档 - How to find the document in mongodb where array size is greater than 1 如何过滤此数组中大于或等于90的标记? - How do I filter marks greater than or equal to 90 in this array? 查找字段大于嵌入数组长度的文档 - Find documents having a field greater than the length of an embeded array 如何在使用 lodash 过滤 mongoDB 集合数组时使用“大于”? - How to use 'greater than' while filtering with lodash an array of mongoDB collection?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM