Reputation: 2071
Yesterday I reindexed my collection. It has over two million documents.
Searching through a Mongodb client (robomongo) I have results in little time:
db.items.find({$text: {$search: "The Long Haul"}})
http://cl.ly/image/182B1P2D1h2n
However, performing a search with Mongoid text_search:
Item.text_search(term).execute
query takes forever (over 2 minutes) (some other searches through text_search take much less time).
D, [2014-12-19T17:56:07.598777 #66067] DEBUG -- : MOPED: 22.22.22.22:43700 COMMAND database=production command={:text=>"items", :search=>"\"The\"\"Long\"\"Haul\""} runtime: 131198.9850ms
OVER
131.199424
Does text_search perform the query any different from the "raw" text search?
Upvotes: 0
Views: 387
Reputation: 2460
Dont know if you figured this out, but I ran across your question while looking for reasons Mongoid .text_search
does not work in MongoDB 3.0.
The current MongoDB docs recommend running queries on a text index like this from the shell;
db.items.find({$text: {$search: "The Long Haul"}})
The Mongoid .text_search method uses the text
command that has been removed in 3.0. Here is an example from the shell,
db.items.runCommand( "text", { search: "The Long Haul"} )
This may explain the performance difference between your two queries.
Incase it will help, the following syntax works from Mongoid on Mongodb 3.0;
Item.where({ :$text => { :$search => "The Long Haul"} } )
Upvotes: 1