Reputation: 121
I'm doing a query that should result with True/False, if there's at least one result for this query True else False, no extra data is needed.
Is there a way to query Elasticsearch so it will use only the index(analyzer) and return results by it? so it won't reach the real data blocks for the results?
Upvotes: 0
Views: 52
Reputation: 1395
Set the size = 0 in query and check hits.total > 0 for to check whether there is any result or not.
{
"size":0,
"query": {
// your search
}
}
Upvotes: 0
Reputation: 1082
In your query add "_source": "false". Like this:
{"_source": "false",
"query": ...
}
This will only search for hits and won't access the stored fields for retrieval.
Upvotes: 1