How can i make a fulltext search on filter param like mongodb said in the ducument:
http://docs.mongodb.org/manual/reference/operator/query/text/
Please help me....thanks
Example:
Book.search = function(text, callback) {
var mongodb = Book.getDataSource().connector.collection(Book.modelName);
mongodb.find({ $text: { $search: "computer" }}, function(err, books){
callback(null, books);
});
});
i'm done. Thanks god.
What, how did you solve this?
Something like
http://mysite.com/api/MongoModel?filter={"$text":{"$search":"california"}}
would be perfectly valid.
Is it still working on the latest version? Or am I missing something?
MongoDB text index successfully created and I can run this directly in mongo, which works fine:
db.Job.find({ $text: { $search: "manager" } })
However running this API returning ALL results instead:
http://mysite.com/api/Jobs?filter={"$text":{"$search":"manager"}}
Actually, it doesn't work with loopback just for Collection.find
How did you get this working?
How did you get this working?
If anyone is still looking to make this work. Was able to get this working on the latest connector code by tweaking the format of the clause.
{ where: { '$text': { search: "search term" } } }
This works because the connector will treat $text as a conditional and auto append $ to the search key.
I don't know how you made that work, but I keep getting.
{ where: { '$text': { search: keyword } } }
---> MongoError: unknown operator: $$text
If I get rid of the $ and just put text then
---> MongoError: unknown operator: $text
And yes I do have indexes on my collection
This call works for me
http://localhost:3000/api/items?filter={"where":{"$text":{"search":"search term"}}}
I hope this will help
try adding "allowExtendedOperators": true on your datasources.json mongodb connector
http://localhost:8080/api/Logs?filter[where][$text][search]=ERROR
Hey guys
I get back empty array on the search result. Do you know what's the problem?
I have collection like this
{
"description": "xxxx",
"id": "5c11f7a00d12b470d915e609"
},
I created a text index on it like this
db.Task.createIndex({ "$**": "text" })
And query it like this
{ "where": { "$text": { "search": "x"} } }
But all I get is an empty array.
@hayk94
var tempCollection=db.Task
tempCollection.createIndex({'$**': 'text'});
var result = tempCollection.find({$text: {$search: 'ccccc'}});
result.toArray(function(err, doc) {
console.log(doc);
});
=====================
tempCollection save
{
name:"aaaa",
value:"ccccc"
}
===================== test result
search c is empty
search ccccc is exist
Most helpful comment
If anyone is still looking to make this work. Was able to get this working on the latest connector code by tweaking the format of the clause.
{ where: { '$text': { search: "search term" } } }
This works because the connector will treat $text as a conditional and auto append $ to the search key.