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.

Remon Nashid
  • 120
  • 1
  • 7
  • btw, I've tried db.executeDbCommand({text:'comics', search:"you"},function(err, result) {});. result.documents['results'] variable is always an empty array, though. – Remon Nashid Jun 08 '13 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. – jimoleary Jun 08 '13 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 } – Remon Nashid Jun 09 '13 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 `"||||||"` rather than `"||||||"` which means that my keywords are not even passed. – Remon Nashid Jun 09 '13 at 15:53

2 Answers2

1

I found that as an equivalent:

collection.find({ $text: { $search : "your search words" }})
  .toArray(function(err,results) {
    // ..callback stuff..
});
user3707805
  • 105
  • 2
  • 7
0

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

Remon Nashid
  • 120
  • 1
  • 7