How to force Spark to use Shuffle Hash Join when it defaults to Sort Merge Join?
February 19, 2021What is the difference between hadoop fs put and copyFromLocal?
February 24, 2021Elasticsearch offers 2 different contexts on how you have query or filter documents in an index – Query context and Filter context.
Query context
- In the query context, a query clause answers the question “How well does this document match this query clause?”
- In query context, Elasticsearch tries to determine whether the document matches the search text and how well it matches.
- Will provide a relevance _score in the output which tells you the relevance of the match result.
- Results are not cached
Eg. book_description field contains the word amazingly realistic.
Filter context
- In a filter context, a query clause answers the question “Does this document match this query clause?”
- Filter context evaluates to a simple “Yes” or “No”
- Doesn’t provide you with relevance _score
- Frequently used filters will be cached automatically by Elasticsearch, to speed up performance.
Eg. book_status field is published
Example
curl -X GET "localhost:9200/book/_search?pretty" -H 'Content-Type: application/json' -d' { "query": { "bool": { "must": [ { "match": { "book_description": "amazingly realistic" }} ], "filter": [ { "term": { "book_status": "published" }} ] } } } '