So I'm using Node.js with MongoDB for my web application. I'm having some trouble creating a text index for my schema and searching for text within an array. I've looked at the mongo docs but haven't found anything related to this specifically.
My current implementation searches successfully on regular String values, but querying for text matching in [String]'s don't return anything.
Here's my REST call:
...console.log("Query string: " + str); var qry = { "$text": { "$search": str } }; model.find(qry, function (err, results) {...
And when I create my schema:
var blah = new Schema({ foo : String, bar : [String],
...
blah.index({ foo: 'text', bar: 'text' });
Any query won't return the results that match in bar
. A query string for something within foo
works fine.
Aucun commentaire:
Enregistrer un commentaire