liveBook · Manning

$$SEARCH_META

As explained in MongoDB 8.0 in Action, Third Edition

$$SEARCH_META is an aggregation variable containing metadata produced by a preceding Atlas Search query.

$$SEARCH_META is an aggregation variable containing metadata from a preceding Atlas Search $search stage. The matching documents flow through the pipeline separately; supported stages after $search can use the variable to inspect the search metadata, including total document counts. section 11.5.1

Inspect a fuzzy search

Search business_name for the misspelled query “smok skop,” allowing one typo while requiring the first three letters to match. A following $facet stage can show five matching inspection documents and expose search metadata through $$SEARCH_META. section 11.5.1

How MongoDB 8.0 in Action, Third Edition covers it

How deep it goes
Defines the variable and works through a faceted search, without detailing metadata fields beyond examples such as total counts.
Examples
Uses a misspelled business-name query to display five inspection matches alongside search metadata.
What it assumes
Uses an Atlas Search index and aggregation pipeline; introduces the variable's role explicitly.
What you can do after
Apply it via Atlas Search to inspect query metadata alongside matching documents.
How it connects
Links Atlas Search, $search, fuzzy search, and $facet within an aggregation pipeline.

This explainer was generated by Manning's knowledge graph from the text of MongoDB 8.0 in Action, Third Edition. The section links point to the parts of the book it draws on.