Meteor.publish() - how to get documents by free text

I trying to get documents by free text.
This part, that getting data by field works OK and returns data:

Meteor.publish("messages", function(){
    return Messages.find({ discussion_id: "discus_id_87" });
});

This one doesn’t work:

Meteor.publish("messages", function(){
    return Messages.find({ $text: { $search: "Some text" } });
});

Returns an ERROR:

 Error: Exception while polling query {"collectionName":"messages","selector":{"$text":{"$search":"Some text"}},"options":{"transform":null}}: Unable to execute query: error processing query: ns=meteor.messages limit=0 skip=0

This is an example from mongoDB $text

db.articles.find( { $text: { $search: "bake coffee -cake" } } )

What I’m doing wrong?
How to get documents by free text?

Thanks

and you created the text index?

2 Likes