This set of MongoDB Multiple Choice Questions & Answers (MCQs) focuses on “Text Search”.
1. When creating a text index on multiple fields, you can specify the individual fields or you can use wildcard specifier ______
a) ($*)
b) (**$**)
c) ($**)
d) None of the mentioned
View Answer
Explanation: You can create a text index on the field or fields whose value is a string or an array of string elements.
2. Point out the wrong statement.
a) In order to drop a text index, use the index name
b) The default language associated with the indexed data determines the rules to parse word roots and ignore stop words
c) To allow for text search on all fields with string content, use the wildcard specifier ($$$) to index all fields that contain string content
d) None of the mentioned
View Answer
Explanation: In the aggregation pipeline, text search is available via the use of the $text query operator in the $match stage.
3. The default language for the indexed data is ________
a) chinese
b) english
c) spanish
d) none of the mentioned
View Answer
Explanation: To specify a different language, use the default_language option when creating the text index.
4. If a collection contains documents or embedded documents that are in different languages, include a field named _______ in the documents.
a) operator
b) lang
c) language
d) all of the mentioned
View Answer
Explanation: MongoDB will use the specified language for that document or embedded document when building the text index.
5. Point out the correct statement.
a) After 2.4, you can terminate both background index builds and foreground index builds
b) The specified language in the document overrides the default language for the text index
c) The text index, like other indexes, should not fall within the index name length limit
d) None of the mentioned
View Answer
Explanation: To get the names of the indexes, use the db.collection.getIndexes() method.
6. To use a field with a name other than language, include the ________ option when creating the index.
a) language_over
b) language_override
c) langoverride
d) none of the mentioned
View Answer
Explanation: You cannot combine the $text query, which requires a special text index, with a query operator that requires a different type of special index.
7. The default name for the index consists of each indexed field name concatenated with _______
a) _char
b) _textc
c) _text
d) All of the mentioned
View Answer
Explanation: Whether the text index has the default name or you specified a name for the text index, to drop the text index, pass the index name to the db.collection.dropIndex() method.
8. To avoid creating an index with a name that exceeds the index name length limit, you can pass the _____ option to the db.collection.createIndex() method.
a) name
b) lang
c) number
d) all of the mentioned
View Answer
Explanation: The measuring units for the maximum distance are determined by the coordinate system in use.
9. The default weight is ____ for the indexed fields.
a) 1
b) 2
c) 3
d) 4
View Answer
Explanation: To adjust the weights for the indexed fields, include the weights option in the db.collection.createIndex() method.
10. For a ______ index, the weight of an indexed field denotes the significance of the field relative to the other indexed fields in terms of the score.
a) unique
b) natural
c) text
d) all of the mentioned
View Answer
Explanation: If the compound text index includes keys preceding the text index key, to perform a $text search, the query predicate must include equality match conditions on the preceding keys.
Sanfoundry Global Education & Learning Series – MongoDB.
Here’s the list of Best Books in MongoDB.
- Practice Programming MCQs
- Check Information Technology Books
- Check MongoDB Books
- Apply for Programming Internship