The text index has the following fields and weights: 

• content has a weight of 10, 

• keywords has a weight of 5, and 

• about has the default weight of 1. 

weights: { content: 10, keywords: 5, }, name: "TextIndex" } ) 

These weights denote the relative significance of the indexed fields to each other. For instance, a term match in the content field has: 

• 2 times (i.e. 10:5 ) the impact as a term match in the keywords field and 

• 10 times (i.e. 10:1 ) the impact as a term match in the about field. 

## Limit the Number of Entries Scanned 

This tutorial describes how to create indexes to limit the number of index entries scanned for queries that includes a $text expression and equality conditions. 

A collection inventory contains the following documents: 

{ _id: 1, dept: "tech", description: "lime green computer" } { _id: 2, dept: "tech", description: "wireless red mouse" } { _id: 3, dept: "kitchen", description: "green placemat" } { _id: 4, dept: "kitchen", description: "red peeler" } { _id: 5, dept: "food", description: "green apple" } { _id: 6, dept: "food", description: "red potato" } 

Consider the common use case that performs text searches by individual departments, such as: 

db.inventory.find( { dept: "kitchen", $text: { $search: "green" } } ) 

To limit the text search to scan only those documents within a specific dept , create a compound index that first spec- ifies an ascending/descending index key on the field dept and then a text index key on the field description : 

db.inventory.createIndex( { dept: 1, description: "text" } ) 

Then, the text search within a particular department will limit the scan of indexed documents. For example, the following query scans only those documents with dept equal to kitchen : 

db.inventory.find( { dept: "kitchen", $text: { $search: "green" } } ) 

## Note: 

• A compound text index cannot include any other special index types, such as multi-key (page 491) or geospa- tial (page 495) index fields. 

