1

I'd like to use full text search available in MongoDB 2.4. Text search is available through runCommand function e.g. db.collection.runCommand( "text", { search: "keywords"}). So, I'm wondering whether there is an equivalent to runCommand() function in mongojs or node-mongodb-native modules.

I know the question has been touched before but was never answered sufficiently. Thanks in advance.

4
  • btw, I've tried db.executeDbCommand({text:'comics', search:"you"},function(err, result) {});. result.documents['results'] variable is always an empty array, though. Commented Jun 8, 2013 at 18:50
  • 1
    The invocation looks correct to me. Are you sure you're not just getting an error ? For example, when I try the command without enabling text search I get something like { documents: [ { ok: 0, errmsg: 'text search not enabled' } ] ...} but note that err from the callback was still null. Even if you have text search enabled you still might be getting another error. Commented Jun 8, 2013 at 21:21
  • Thanks for your comment jimoleary. AFAICS there are no errors, here is the response: { documents: [ { queryDebugString: '||||||', language: 'english', results: [], stats: [Object], ok: 1 } ], index: 200, messageLength: 200, requestId: 2, responseTo: 3, responseFlag: 8, cursorId: { bsontype: 'Long', low: 0, high_: 0 }, startingFrom: 0, numberReturned: 1 } Commented Jun 9, 2013 at 15:49
  • btw, 'comics' in aforementioned example is supposed to be the collection. Also, when I run the command from mongo shell I do get results, and queryDebugString key equals "<keywords>||||||" rather than "||||||" which means that my keywords are not even passed. Commented Jun 9, 2013 at 15:53

2 Answers 2

1

I found that as an equivalent:

collection.find({ $text: { $search : "your search words" }})
  .toArray(function(err,results) {
    // ..callback stuff..
});
Sign up to request clarification or add additional context in comments.

Comments

0

runCommand support has been added! https://github.com/gett/mongojs/issues/62

1 Comment

Were you able to get mongojs working for this? I've tried with no luck.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.