Skip to main content
InterviewHubPRO
Section Overview
Q43

Question 43 of 50

Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

86%
Elasticsearch & Lucene (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

Query Context vs Filter Context: Why filters use bitsets and avoid scoring, boosting search performance.

senior LevelFormsPerformance

In Simple Words:

  • Query Context ("query": { "match": ... }): Asks "How well does this document match the query?". Lucene calculates TF-IDF / BM25 relevance score for every matching document. Non-cacheable and CPU intensive.
  • Filter Context ("filter": { "term": ... }): Asks a binary "Does this document match? Yes or No".
    • Bypasses scoring entirely.
    • Generates compact in-memory Bitsets (Roaring bitmaps) that are cached automatically in the Node Query Cache. Subsequent identical filters execute in microseconds!