Elasticsearch & Lucene (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)
What is the difference between a Match Query and a Term Query?
junior LevelCode ExampleelasticsearchBasic
In Simple Words:
- Match Query: The query string is passed through the analyzer (lowercased, stemmed, tokenized) before searching the inverted index. Used for full-text fields (
text). - Term Query: The query string is looked up verbatim without any analysis. Used strictly for exact matches on
keywordfields (e.g. numbers, booleans, exact tags).
json
// Term query for exact status match:
{
"query": {
"term": { "status": "active" }
}
}