要做全文搜索,rails + mogo 参考的是https://ruby-china.org/topics/21473 这篇文章 之前是查询成功了的,但是我修改和删除了一部分数据,再查询 s.results 的时候报
Mongoid::Errors::DocumentNotFound:
message:
Document(s) not found for class CompanyDatas with id(s) 56b31a9e5c216e69cd000000, 56cd36675c216e2bbd000297, 56b31a9e5c216e69cd000001, 56b31a9e5c216e69cd000002, 56b31a9e5c216e69cd000003, 56b301615c216e62c500040e, 56c9cc1a5c216e6413000503, 56c9faaa5c216e641306d216, 56c9faaf5c216e641306d379, 56c9f9c15c216e641306af48, 56c9f6be5c216e6413063d36, 56cd35e95c216e2bbd0001c7, 56d69bb25c216e6c6e000866, 56d69c4a5c216e6c6e001c4a, 56b3017f5c216e62c5000c75, 56b301ca5c216e62c5001e4a, 56c9cec15c216e64130062ed, 56c9cee45c216e6413006949, 56c9cf9d5c216e6413008239, 56c9cff35c216e6413008ed8, 56b3017f5c216e62c5000c79, 56b301845c216e62c5000df1, 56b301a35c216e62c5001572, 56b31aa35c216e69cd000122, 56b31aa45c216e69cd00012b, 56b31aa45c216e69cd00015a, 56b31aa45c216e69cd000161, 56b31aa55c216e69cd000178, 56b31aa85c216e69cd00023a, 56b31ac25c216e69cd0007ce.
summary:
When calling CompanyDatas.find with an id or array of ids, each parameter must match a document in the database or this error will be raised. The search was for the id(s): 56b31a9e5c216e69cd000000, 56cd36675c216e2bbd000297, 56b31a9e5c216e69cd000001 ... (30 total) and the following ids were not found: 56b31a9e5c216e69cd000000, 56cd36675c216e2bbd000297, 56b31a9e5c216e69cd000001, 56b31a9e5c216e69cd000002, 56b31a9e5c216e69cd000003, 56b301615c216e62c500040e, 56c9cc1a5c216e6413000503, 56c9faaa5c216e641306d216, 56c9faaf5c216e641306d379, 56c9f9c15c216e641306af48, 56c9f6be5c216e6413063d36, 56cd35e95c216e2bbd0001c7, 56d69bb25c216e6c6e000866, 56d69c4a5c216e6c6e001c4a, 56b3017f5c216e62c5000c75, 56b301ca5c216e62c5001e4a, 56c9cec15c216e64130062ed, 56c9cee45c216e6413006949, 56c9cf9d5c216e6413008239, 56c9cff35c216e6413008ed8, 56b3017f5c216e62c5000c79, 56b301845c216e62c5000df1, 56b301a35c216e62c5001572, 56b31aa35c216e69cd000122, 56b31aa45c216e69cd00012b, 56b31aa45c216e69cd00015a, 56b31aa45c216e69cd000161, 56b31aa55c216e69cd000178, 56b31aa85c216e69cd00023a, 56b31ac25c216e69cd0007ce.
resolution:
Search for an id that is in the database or set the Mongoid.raise_not_found_error configuration option to false, which will cause a nil to be returned instead of raising this error when searching for a single id, or only the matched documents when searching for multiples.
from /usr/local/lib/ruby/gems/2.1.0/gems/mongoid-5.0.1/lib/mongoid/criteria.rb:508:in `check_for_missing_documents!'
from /usr/local/lib/ruby/gems/2.1.0/gems/mongoid-5.0.1/lib/mongoid/criteria/findable.rb:20:in `execute_or_raise'
from /usr/local/lib/ruby/gems/2.1.0/gems/mongoid-5.0.1/lib/mongoid/criteria/findable.rb:40:in `find'
from /usr/local/lib/ruby/gems/2.1.0/gems/sunspot_mongo-1.2.1/lib/sunspot/mongo.rb:34:in `load_all'
from /usr/local/lib/ruby/gems/2.1.0/gems/sunspot-2.2.4/lib/sunspot/search/hit_enumerable.rb:32:in `block in populate_hits'
from /usr/local/lib/ruby/gems/2.1.0/gems/sunspot-2.2.4/lib/sunspot/search/hit_enumerable.rb:28:in `each_pair'
from /usr/local/lib/ruby/gems/2.1.0/gems/sunspot-2.2.4/lib/sunspot/search/hit_enumerable.rb:28:in `populate_hits'
from /usr/local/lib/ruby/gems/2.1.0/gems/sunspot-2.2.4/lib/sunspot/search/hit.rb:90:in `result'
from /usr/local/lib/ruby/gems/2.1.0/gems/sunspot-2.2.4/lib/sunspot/search/hit_enumerable.rb:15:in `block in verified_hits'
from /usr/local/lib/ruby/gems/2.1.0/gems/sunspot-2.2.4/lib/sunspot/search/hit_enumerable.rb:15:in `select'
from /usr/local/lib/ruby/gems/2.1.0/gems/sunspot-2.2.4/lib/sunspot/search/hit_enumerable.rb:15:in `verified_hits'
from /usr/local/lib/ruby/gems/2.1.0/gems/sunspot-2.2.4/lib/sunspot/search/abstract_search.rb:291:in `verified_hits'
from /usr/local/lib/ruby/gems/2.1.0/gems/sunspot-2.2.4/lib/sunspot/search/abstract_search.rb:70:in `results'
from (irb):5
from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.5/lib/rails/commands/console.rb:110:in `start'
from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.5/lib/rails/commands/console.rb:9:in `start'
from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:68:in `console'
from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.5/lib/rails/commands.rb:17:in `<top (required)>'
from bin/rails:4:in `require'
但是 company.total 查询数量的时候,正常 百度各种搜不到,请教各位大神了