liveBook · Manning

Keyword query

As explained in MongoDB 8.0 in Action, Third Edition

A search query is an expression specifying terms, phrases, conditions, or patterns to match against indexed content.

A keyword query specifies terms or phrases to match against indexed content. Apache Lucene tokenizes and normalizes query text, matches tokens through an inverted index, and ranks returned documents by relevance. section 11.2

Lucene query behavior varies with the terms supplied:

  • "No Violation Issued Mobile Food Vendor - 881" matches both sample documents because both contain the two query tokens. section 11.2
  • "No Violation Issued BRONX" returns only the document containing both the result and city terms. section 11.2
  • "Mobile Food Vendor - 881 PALMER AVE" produces a precise match for the document containing both sector and street terms. section 11.2
  • Logical operators such as AND, OR, and NOT can refine which indexed documents match. section 11.2
Table 11.1 Apache Lucene inverted index

Token

Document 1

Document 2

LISANDRO CABRERA

+

AZMY KIROLES

+

BRONX

+

JERSEY CITY

+

PALMER AVE

+

VROOM ST

+

10475

+

+

7306

2234

+

160

+

NO VIOLATION ISSUED

+

+

MOBILE FOOD VENDOR - 881

+

+

JUL 17 2015

+

DEC 23 2015

+

The inverted-index listing maps normalized tokens such as BRONX, PALMER AVE, and NO VIOLATION ISSUED to the documents containing them. section 11.2

How MongoDB 8.0 in Action, Third Edition covers it

How deep it goes
Explains tokenization, lowercasing, inverted-index matching, relevance scoring, and logical operators.
Examples
Uses food-vendor, city, and street queries against two inspection documents.
What you can do after
Evaluate/understand how query terms retrieve documents and influence their relevance scores.
How it connects
Links keyword queries to tokenization, inverted indexes, relevance scoring, and logical operators.

Also explained in

Compare how 3 books explain keyword query →

Related concepts

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.