liveBook · Manning

Phrase matching

As explained in AI-Powered Search

Phrase search retrieves documents containing a specified sequence of consecutive terms, typically in the same order.

Phrase matching searches for a specified sequence of terms, usually preserving their order and adjacency. In search content, characters form sequences, sequences form terms, and sequential terms form phrases such as “software engineer” or “senior software engineer.” section 2.2

The distinction from broader term-sequence matching is important: “chief executive officer” is sequential, while “chief officer” with a positional allowance is not necessarily adjacent. Search systems may also treat single terms as phrases for convenience. section 2.2

Phrase features in ranking

A learning-to-rank model can use phrase matching as a relevance signal alongside fuzzy matching. For example, name_bigram performs a two-word phrase search on the name field, while short_description_bigram performs the same operation on short_description. Training and evaluation then test whether these features improve ranking on search sessions. section 12.2.1

Listing 12.3 A new model improved by changing the features
feature_set = [
  ltr.generate_fuzzy_query_feature(feature_name="name_fuzzy",
                                   field_name="name"),
  ltr.generate_bigram_query_feature(feature_name="name_bigram",
                                    field_name="name"),
  ltr.generate_bigram_query_feature(feature_name="short_description_bigram"
                                    field_name="short_description")]

evaluation = train_and_evaluate_model(sessions, "ltr_model_variant_2",
                                      feature_set)
display(evaluation)

Inspect the feature-set listing to see phrase matching represented as configurable bigram query features in a ranking pipeline. section 12.2.1

Phrase matching also supports semantic search pipelines: phrases can be learned from documents or user signals, extracted from incoming queries, and used when rewriting queries to interpret intent. section 6.6

How AI-Powered Search covers it

How deep it goes
Defines sequential terms and demonstrates configurable bigram features, but does not detail index-level phrase-matching internals.
Examples
Uses “software engineer,” “chief executive officer,” name_bigram, and short_description_bigram as phrase examples.
What it assumes
Assumes familiarity with terms, fields, queries, and documents while defining phrase structure from characters upward.
What you can do after
Apply phrase matching through configurable bigram features and evaluate its contribution to ranking quality.
How it connects
Connects phrase matching with fuzzy search, learning to rank, semantic search, query rewriting, and query intent.

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.