MongoDB Questions and Answers – Text Search

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

Answer: c
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

Answer: c
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

Answer: b
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

Answer: b
Explanation: MongoDB will use the specified language for that document or embedded document when building the text index.

advertisement
advertisement

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

Answer: b
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

Answer: b
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.

Note: Join free Sanfoundry classes at Telegram or Youtube

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

Answer: c
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

Answer: a
Explanation: The measuring units for the maximum distance are determined by the coordinate system in use.

advertisement

9. The default weight is ____ for the indexed fields.
a) 1
b) 2
c) 3
d) 4
View Answer

Answer: a
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

Answer: b
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.

advertisement

Sanfoundry Global Education & Learning Series – MongoDB.

Here’s the list of Best Books in MongoDB.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.