We have a situation where a user would like to have a single 'omni-box' for searching for a word\phrase anywhere in a document.
Is MongoDB able to perform this search or would it have to be an explicit search of every field?
You need to create a wildcard text indexes like this:
db.collection.createIndex( { "$**": "text" } )
You can the use the $text
operator to performs a text search.
As mentioned in the documentation:
This index allows for text search on all fields with string content. Such an index can be useful with highly unstructured data if it is unclear which fields to include in the text index or for ad-hoc querying.