A search for children’s books might need to exclude adult titles before deciding which remaining book is most relevant. Filtering performs that exclusion: it narrows indexed documents to a set of possible answers. Ranking scores and orders those answers. A filter decides whether a document qualifies, not where it belongs in the results. section 3.2.4 section 3.2.6
Filtering first can reduce the number of documents that need relevance scores, improving response time. It also supports counts of matching documents and facets—counts by field value that help users narrow results further. Filtering is not mandatory: a dense-vector search may have no keywords or attributes suitable for an initial filter and instead score documents to find its results. section 3.2.4
Keep three request controls distinct:
- Use filters for eligibility alone, such as category = books and audience = kid. section 3.2.6
- Expect an ordinary query to do two jobs: restrict matches and contribute features to relevance scoring. A 100% minimum match on a description query also excludes documents missing any required query value. section 3.2.6
- When scoring should not exclude documents, separate the operations: use a match-all query, put the eligibility rule in filters, and put the relevance contribution in a boost query. Modeling the query as a function is another option. section 3.2.6
Generic search request syntax:
{"query": "the cat in the hat",
"query_fields": ["description"],
"filters": [("category", "books"), ("audience", "kid")],
"min_match": "100%"}
Solr request syntax:
{"query": "the cat in the hat",
"filters": ["category:books", "audience:kid"],
"params": {"qf": ["description"],
"mm": "100%",
"defType": "edismax"}}
Compare the generic request with its Solr form: category and audience are explicit filters, while the description query also filters because its minimum match is 100%. section 3.2.6
Filtering suggestions before autocomplete
Filtering can also prepare data rather than search results. After extracting concepts from an outdoors corpus, a Python dictionary comprehension keeps only concepts whose frequency exceeds five. That cutoff removes some rare terms and misspellings that would add noise to autocomplete suggestions. section 13.5.1
































