Document_Missing_Exception While Performing Elasticsearch Update

Document_Missing_Exception While Performing Elasticsearch Update

I went through several questions with the same "document_missing_exception" problem but looks like they aren't the same problem in my case. I can query the document, but failed when I tried to updated it. My query:

# search AuthEvent by sessionID
GET events-*/_search
{
  "size": "100",
  "query": {
      "bool": {
          "must": [{
                  "term": {
                      "type": {
                          "value": "AuthEvent"
                      }
                  }
              },
              {
                "term": {
                  "client.sessionID.raw": {
                    "value": "067d660a1504Y67FOuiiRIEkVNG8uYIlnK87liuZGLBcSmEW0aHoDXAHfu"
                  }
                }
              }
          ]
      }
  }
}

Query result:

{
  "took" : 18,
  "timed_out" : false,
  "_shards" : {
    "total" : 76,
    "successful" : 76,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 6.705622,
    "hits" : [
      {
        "_index" : "events-2020.10.06",
        "_type" : "doc",
        "_id" : "2c675295b27a225ce243d2f13701b14222074eaf",
        "_score" : 6.705622,
        "_routing" : "067d660a1504Y67FOuiiRIEkVNG8uYIlnK87liuZGLBcSmEW0aHoDXAHfu",
        "_source" : {
          # some data
        }
      }
    ]
  }
}

Update request:

POST events-2020.10.06/_doc/2c675295b27a225ce243d2f13701b14222074eaf/_update
{
  "doc" : {
    "custom" : {
      "testField" : "testData"
    }
  }
}

And update result:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "document_missing_exception",
        "reason" : "[_doc][2c675295b27a225ce243d2f13701b14222074eaf]: document missing",
        "index_uuid" : "5zhQy6W6RnWscDz7Av4_bA",
        "shard" : "1",
        "index" : "events-2020.10.06"
      }
    ],
    "type" : "document_missing_exception",
    "reason" : "[_doc][2c675295b27a225ce243d2f13701b14222074eaf]: document missing",
    "index_uuid" : "5zhQy6W6RnWscDz7Av4_bA",
    "shard" : "1",
    "index" : "events-2020.10.06"
  },
  "status" : 404
}

I'm quite new to ElasticSearch and couldn't find any reason for such behaviour. I use ElasticSearch 6.7.1 oss version + Kibana for operating with data. I also tried with bulk update but ended with same error.

1 Answer

As you can see in the query results, your document has been indexed with a routing value and you're missing it in your update request.

Try this instead:

POST events-2020.10.06/_doc/2c675295b27a225ce243d2f13701b14222074eaf/_update?routing=067d660a1504Y67FOuiiRIEkVNG8uYIlnK87liuZGLBcSmEW0aHoDXAHfu
{
  "doc" : {
    "custom" : {
      "testField" : "testData"
    }
  }
}

If a document is indexed with a routing value, all subsequent get, update and delete operations need to happen with that routing value as well.

1

Your Answer

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

Elena Rostova
Author

Elena Rostova

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.