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