Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby Rails 4和Mongo DB 4.x在“;“大”;收集_Ruby_Mongodb_Ruby On Rails 4_Mongoid_Mongodb Query - Fatal编程技术网

Ruby Rails 4和Mongo DB 4.x在“;“大”;收集

Ruby Rails 4和Mongo DB 4.x在“;“大”;收集,ruby,mongodb,ruby-on-rails-4,mongoid,mongodb-query,Ruby,Mongodb,Ruby On Rails 4,Mongoid,Mongodb Query,有了Mongo支持的模型和大约800-900条记录,我正试图迭代并使用一些属性生成CSV 看起来是这样的: each do |car| csv << columns.map { |column| car.__send__(column) } end A Moped::Errors::QueryFailure occurred in cars#index: The operation: #<Moped::Protocol::Query @length=94 @

有了Mongo支持的模型和大约800-900条记录,我正试图迭代并使用一些属性生成CSV

看起来是这样的:

each do |car|
  csv << columns.map { |column| car.__send__(column) }
end
A Moped::Errors::QueryFailure occurred in cars#index:

  The operation: #<Moped::Protocol::Query
  @length=94
  @request_id=376
  @response_to=0
  @op_code=2004
  @flags=[]
  @full_collection_name="app555555.cars"
  @skip=0
  @limit=0
  @selector={"$query"=>{}, "$orderby"=>{"created_at"=>-1}}
  @fields=nil>
failed with error 10128: "too much data for sort() with no index.  add an index or specify a smaller limit"

See https://github.com/mongodb/mongo/blob/master/docs/errors.md
for details about this error.
  app/models/car.rb:84:in `block in to_csv'
每辆车|

csv您可能缺少索引。这里有更多关于在mongo DB中添加索引的内容,谢谢grimsock,我已经在默认顺序列中添加了索引(它是在
创建的),并且可以正常工作!