I'm asking this question after studying MongoDB text search and keyword indexes. I also found a similar question, but adding an array to each document containing all the field values seems like a kludgy solution. Thus this question.
We need to write a query that will return documents where any field matches a search string.
Our first thought was to write a query along these lines:
db.collection.find( { field_one: /search string/i,
field_two: /search string/i,
field_three: /search string/i } );
Our challenge is that the fields will vary between documents, so we can't hard-code the field names in the query.
Is something like the following pseudocode possible with MongoDB?
db.collection.find( { [any field]: /search string/i } );