POST /ankita-inex/my_type/_bulk
{ "index": { "_id": 1 }}
{ "title": "The quick brown fox" }
{ "index": { "_id": 2 }}
{ "title": "The quick brown fox jumps over the lazy dog" }
{ "index": { "_id": 3 }}
{ "title": "The quick brown fox jumps over the quick dog" }
{ "index": { "_id": 4 }}
{ "title": "Brown fox brown dog" }
This gets succesfully posted but i wanted to use exists query for usingMissingQuery
GET /ankita-inex/my_type/_search
{
"query" : {
"bool": {
"must": {
"exists" : {
"index" : "4"
}
}
}
} }
{
"error":
{
"root_cause": [
{
"type": "query_parsing_exception",
"reason": "[exists] query does not support [index]",
"index": "ankita-inex",
"line": 6,
"col": 20
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "ankita-inex",
"node": "pbwST3JVSlq3sPqBgWoAVg",
"reason": {
"type": "query_parsing_exception",
"reason": "[exists] query does not support [index]",
"index": "ankita-inex",
"line": 6,
"col": 20
}
}
]
},
"status": 400
}
The
exists
query is to find documents having a given named field, not for checking the exact value. If you have to see if document with_id: 4
exists, you can do it like this:Or simply like this:
This will return the document if it exists