Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.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 on rails 如何使用sunspot仅搜索选定记录中的文本_Ruby On Rails_Ruby_Sunspot_Sunspot Rails_Sunspot Solr - Fatal编程技术网

Ruby on rails 如何使用sunspot仅搜索选定记录中的文本

Ruby on rails 如何使用sunspot仅搜索选定记录中的文本,ruby-on-rails,ruby,sunspot,sunspot-rails,sunspot-solr,Ruby On Rails,Ruby,Sunspot,Sunspot Rails,Sunspot Solr,如何在选定记录中搜索文本,而不是在模型的所有记录中 nodes_res = Node.where(id: ids) search = nodes_res.search { keywords "query" } 但是太阳黑子会在模型的所有记录中搜索:(我还没有测试过这个,但它看起来是你想要的 请参见此示例: # Posts with a category of 1, 3, or 5 Post.search do with(:category_ids, [1, 3, 5]) end 比如说:

如何在选定记录中搜索文本,而不是在模型的所有记录中

nodes_res = Node.where(id: ids)
search = nodes_res.search { keywords "query" }

但是太阳黑子会在模型的所有记录中搜索:(

我还没有测试过这个,但它看起来是你想要的

请参见此示例:

# Posts with a category of 1, 3, or 5
Post.search do
  with(:category_ids, [1, 3, 5])
end
比如说:

Node.search do
  keywords "query"
  with(:ids, [ids])
end

谢谢(这很有帮助)