liveBook · Manning

Filtering

As explained in AI-Powered Search

Filtering is the retrieval operation that excludes items failing specified criteria without necessarily ordering the remaining items by relevance.

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

How AI-Powered Search covers it

How deep it goes
Explains the matching–ranking distinction, performance rationale, and request-parameter choices, without detailing filter execution internals.
Examples
Uses a children’s-book request with category and audience filters and an outdoors-corpus frequency cutoff for autocomplete.
What it assumes
Builds from indexed documents and queries, defining matching versus ranking before showing search request parameters.
What you can do after
Operate/configure it in Solr by separating eligibility filters from query-driven scoring and boost queries.
How it connects
Connects filtering to relevance ranking, dense-vector search, facets, aggregations, and boost queries.

Also explained in

Compare how 33 books explain filtering →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of AI-Powered Search. The section links point to the parts of the book it draws on.