Text Search
텍스트 탐색
- MongoDB에서는 document내에 있는 string을 탐색하는 기능을 제공하고 있다.
Text Index (텍스트 인덱스)
- MongoDB에서 string을 탐색할 때 사용되는 요소이다.
- 텍스트 인덱스는 string Field 혹은 string으로 이루어진 array가 포함될 수 있다.
createIndex Command Prototype
db.<collection_name>.createIndex(keys, options, commitQuorum)
Parameter
|
Type
|
Description
|
keys
|
document
|
A document that contains the field and value pairs
where the field is the index key and the value describes the type of index for that field.For an ascending index on a field, specify a value of 1; for descending index, specify a value of -1. Starting in 3.6, you cannot specify * as the index name. MongoDB supports several different index types including text, geospatial, and hashed indexes. See index types for more information. Changed in version 4.2: MongoDB 4.2 wildcard indexes support workloads where users query against custom fields or a large variety of fields in a collection:
For examples of wildcard index creation, see Create a Wildcard Index.
The mongod featureCompatibilityVersion must be 4.2 to create wildcard indexes. For instructions on setting the fCV, see Set Feature Compatibility Version on MongoDB 5.0 Deployments. |
options
|
document
|
Optional. A document that contains a set of options that controls the creation of the index. See Options for details.
|
integer |
string |
Optional. The minimum number of data-bearing voting replica set members (i.e. commit quorum), including the primary, that must report a successful index build before the primary marks the indexes as ready. A "voting" member is any replica set member where members[n].votes is greater than 0.
Supports the following values:
New in version 4.4.
|
Reference: MongoDB Documentation (URL)