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 有没有办法将两个独立的'Searchkick::Results'对象合并为一个_Ruby_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Searchkick - Fatal编程技术网 elasticsearch,searchkick,Ruby,elasticsearch,Searchkick" /> elasticsearch,searchkick,Ruby,elasticsearch,Searchkick" />

Ruby 有没有办法将两个独立的'Searchkick::Results'对象合并为一个

Ruby 有没有办法将两个独立的'Searchkick::Results'对象合并为一个,ruby,elasticsearch,searchkick,Ruby,elasticsearch,Searchkick,有没有办法将两个独立的Searchkick::Results对象合并为一个 例如 user=user.search(“abc”,其中:{}) blog=blog.search(“abc”,其中:{}) 将两个结果合并为一个Searchkick::results对象,以便使用分页、相关性搜索等。。作为一个整体 我看了一眼,但那似乎不是我想要的 注:我在user=user.search(“abc”,其中:{}) blog=blog.search(“abc”,其中:{}) 将两个对象转换为一个数组,

有没有办法将两个独立的
Searchkick::Results
对象合并为一个

例如

user=user.search(“abc”,其中:{})
blog=blog.search(“abc”,其中:{})
将两个结果合并为一个Searchkick::results对象,以便使用分页、相关性搜索等。。作为一个整体

我看了一眼,但那似乎不是我想要的

注:我在

user=user.search(“abc”,其中:{})

blog=blog.search(“abc”,其中:{})

将两个对象转换为一个数组,并使用
concat
方法合并数组


user\u blog=user.to\u a.concat(blog.to\u a)

您可以使用以下内容跨多个索引进行搜索:

where = {
  _or: [
    {_type: "user", somefield: "value1"},
    {_type: "blog", otherfield: "value2"}
  ]
}
Searchkick.search "abc", index_name: [User, Blog], where: where

这是不同的结果集。我想知道你的用例是什么。嘿@aclook,这是一个搜索页面,不同的标签有不同的范围。例如用户、博客等,您可以搜索每个范围。第一个选项卡称为
All
,希望返回所有范围内的搜索结果
where = {
  _or: [
    {_type: "user", somefield: "value1"},
    {_type: "blog", otherfield: "value2"}
  ]
}
Searchkick.search "abc", index_name: [User, Blog], where: where