I want to check if there are any Elasticsearch documents that exist with specified values. Where is the fastest way to check because I just want to check for existence.
I am looking for implementation in java.
Asked
Active
Viewed 2,129 times
2

Thinh Nguyen Van
- 113
- 2
- 18
-
Hi, have you solved your problem? was my answer helpful? – glenacota Jan 26 '20 at 20:18
1 Answers
1
You're looking for a query in the filter context (see documentation), because Elasticsearch won't calculate the matching score and will cache the result. Using the query DSl, the query might look like:
{
"query": {
"bool": {
"filter": {
"the_field_name": "the_value_to_match"
}
}
}
}
As for the Java API, you'll find your answer in the Elastic documentation: https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-compound-queries.html#java-query-dsl-bool-query

glenacota
- 2,314
- 1
- 11
- 18