How to check document consistent with current mapping?

i need to know if document is matching current mapping or not (if not match i need to reindex) .
eg, i change a field analyzer several times by update mapping . i need to know current document index status is identical to the lastest mapping .
but i don't know which api i need to use . thanks .

please be more specific what 'consistent' means in your context - the question is impossible to answer otherwise

thanks reply , i don't know if someone changed my index's mapping . so i need to know my index need reindex or not . eg , changed the field's analyzer .i just need a api to check like this logic (for each document in index , check if the document is same with the lastest index mapping , if not , i will use update_by_query to update this document )

If you updated the mapping (i.e. by adding a field), you could use the exists query... take a look at this example if it helps you

DELETE test

PUT test

PUT test/_doc/1
{ "key" : "value" }

PUT test/_mapping
{
  "properties": {
    "other" : { "type":"text"}
  }
}

PUT test/_doc/2
{ "other" : "value" }

GET test/_search
{
  "query": {
    "bool": {
      "must_not": [
        { "exists": { "field": "other"}}
      ]
    }
  }
}

acturally i dont know which mapping setting changed since we in a team develop mode but i need to reindex documents according to latest mapping . but i don't want to reindex them all to save some time . (and i even don't know if the mapping really changed or not) .
for my understanding the mapping is like "class" and the index document is the "object" , i need an api like java 's
"object instanceof class"
....

Something like that does not exist, as the concept of instances does not fully map. You could try the above search with any field though.

ok thanks

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.