PROBLEM
There are times and situations when in elasticsearch, while inserting, we don’t set any value at that moment. It is quite possible, we don’t have the value yet set. Like say, we are inserting in some article but at that point of time, we don’t have value to be set for sentiment at the time of insertion. Then the value dose not get set in the document that is indexed. If we see the document, we won’t find the key there even if we have mapped it.
SOLUTION
Now, if we were to find such articles who such keys missing, we can trace the same using scripting
GET articles
{
"from": 0,
"size": 200,
"query": {
"bool": {
"must": {
"script": {
"script": {
"inline": "doc[\"sentiment\"].empty"
}
}
}
}
}
}
OR the same can also be simplified with the new Elasticsearch-SQL
GET _sql?sql=Select * from articles where script('doc["sentiment"].empty')
This way we can get all the records whose values have not been set yet.
3008 BlakDronzer Elastic Search
Total 0 Votes:
0
0