hereischen
hereischen

Reputation: 67

query elasticsearch can get a document by id but not find it in query all

I was using ES 2.3, now I am upgrade it to ES 7.4. The data was generated through auto test.So it will always be 32 documents.

I found when I was using ES 2.3 with query all, I got all 32 documents. The document, for example, data.id: 5dba917f61b48a327c948557 can be found in the result. And I can query it by data.id, the documents can be found as well.

But if I do the same thing using ES 7, I CAN NOT find the document with data.id:5dba917f61b48a327c948557 in query all eg. http://localhost:9200/test-auditing-2019-10/_search?pretty=true results.

{
  "took" : 16,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 32,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "test-auditing-2019-10",
        "_type" : "_doc",
        "_id" : "J0LIIG4Bw-26hPm9OiXO",
...

I do get the documents when query http://localhost:9200/test-auditing-2019-10/_search?q=data.id:5dba917f61b48a327c948557&pretty=true .

...
  "hits" : {
    "total" : {
      "value" : 2,
      "relation" : "eq"
    },
    "max_score" : 2.3795462,
    "hits" : [
      {
        "_index" : "test-auditing-2019-10",
        "_type" : "_doc",
        "_id" : "RELIIG4Bw-26hPm9WyUP",
...

What is wrong? Is this expected? Thanks a lot.

Upvotes: 0

Views: 265

Answers (1)

for_stack
for_stack

Reputation: 22981

ElasticSearch 2.3 is too old, maybe it would return all matched documents. I don't have this version, and cannot reproduce it.

However, modern ElasticSearch only returns 10 matched documents by default, even if your query matches all documents. In order to get more matched documents, you can use the from and size to do pagination:

Get first 32 documents:

http://localhost:9200/test-auditing-2019-10/_search?from=0&size=32&pretty=true

Get the next 32 documents:

http://localhost:9200/test-auditing-2019-10/_search?from=32&size=32&pretty=true

Upvotes: 1

Related Questions