0

I have millions of indexed documents. after indexing I figured that there is an document count mismatch. i want to send array of hundreds of document ids and search at Elastic search if those document ids exists?. and in response get ids that has not Indexed.

example: these are indexed documents

[497499, 497550, 498370, 498476, 498639, 498726, 498826, 500479, 500780, 500918] 

I'm sending 4 at a time

[497599, 88888, 497550, 77777]

response should be whats not at there

[88888, 77777]
6
  • 1
    Did you try a Terms-Query on "_id" field with a boolean query ("must_not") ? Commented Dec 6, 2019 at 15:27
  • @Benjamin - imho , thats answer than comment. Commented Dec 6, 2019 at 16:28
  • hope now the description is more clear @Benjamin Commented Dec 6, 2019 at 18:08
  • @NirmalI update the description "must_not" didn't work for me Commented Dec 6, 2019 at 18:09
  • How could you get in results a document id that hasn't been index? what you can do is to run the "ids" query . it will give you in results which document exists and then you will continue with the logic. Commented Dec 6, 2019 at 19:32

1 Answer 1

1

You should consider using the _mget endpoint and then parse the result like for instance :

GET someidx/_mget?_source=false
{
    "docs" : [
        {
            "_id" : "c37m5W4BifZmUly9Ni-X"
        },
        {
            "_id" : "2"
        }
    ]
}

Result :

{
  "docs" : [
    {
      "_index" : "someidx",
      "_type" : "_doc",
      "_id" : "c37m5W4BifZmUly9Ni-X",
      "_version" : 1,
      "_seq_no" : 0,
      "_primary_term" : 1,
      "found" : true
    },
    {
      "_index" : "someidx",
      "_type" : "_doc",
      "_id" : "2",
      "found" : false
    }
  ]
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.