No Results with Text Search MongoDB PHP -
i trying search text field in collection. example document in collection:
{ "_id" : objectid("51f9c432573906141dbc9996"), "id" : objectid("51f9c432573906141dbc9995"), "body" : "the", "rank" : 0, "num_comm" : 0, "activity" : 1375323186 } this how searching...
$mongo = new mongoclient("mongodb://127.0.0.1"); $db = $mongo->requestry; try { $search_results = $db->command(array('text' => 'trending', 'search' => '"the"')); } catch (mongocursorexception $e) { return array('error' => true, 'msg' => $e->getcode()); } return array('error' => false, 'results' => $search_results); and result get...
{ error: false, results: { querydebugstring: "||||the||", language: "english", results: [ ], stats: { nscanned: 0, nscannedobjects: 0, n: 0, nfound: 0, timemicros: 66 }, ok: 1 } } below indexes on collection...
{ "v" : 1, "key" : { "_id" : 1 }, "ns" : "requestry.trending", "name" : "_id_" }, { "v" : 1, "key" : { "_fts" : "text", "_ftsx" : 1 }, "ns" : "requestry.trending", "name" : "body_text", "weights" : { "body" : 1 }, "default_language" : "english", "language_override" : "language", "textindexversion" : 1 } any ideas on why blank results array every time?
thanks in advance help!
nathan
you can not search "the" because stop-word, , stop-words not indexed. can find list of stop-words @ https://github.com/mongodb/mongo/blob/master/src/mongo/db/fts/stop_words_english.txt
you can see being tried match in debug string:
querydebugstring: "||||the||" the first element empty here, means no match done. if happens '"cat" , "purple"', debug string is:
querydebugstring: "cat|purpl||||cat|purple||" the first element(s) cat|purpl - shows stemming has been applied purple.
Comments
Post a Comment