gpt4 book ai didi

php - 具有不同限制的Elasticsearch索引搜索

转载 作者:行者123 更新时间:2023-12-02 22:33:41 24 4
gpt4 key购买 nike

当人们使用下拉菜单时,我正在使用Elasticsearch服务。到现在为止还挺好。现在,我试图找出是否可以从具有不同排序/过滤器/限制的不同类型中进行搜索。

到目前为止,我已经找到了解决方法,每种类型和种类都可以使用不同的过滤器。我已经通过 bool(boolean) 查询实现了不同的过滤器,使用了shoulds和sorting取决于分数。
我的目标是显示总共10行,其中8行应为产品,2行应为类别。对于类别,此限制应为最大值,如果没有要显示的类别,则应显示10个产品。
我已经阅读了文档,并且可以看到可以将大小设置为查询主体,例如排序。但是排序具有更大的灵活性。因此,是的,有关极限的问题-是否有办法实现?

最佳答案

您想要的似乎是现场折叠或分组。

Elasticsearch问题跟踪器上有一个针对该功能的长期待解决的问题:https://github.com/elasticsearch/elasticsearch/issues/256,最新的更新是(来自http://www.elasticsearch.com/blog/from-amsterdam-with-love-elasticsearchs-second-company-all-hands/),尽管正在取得进展,但它不会在1.0发布之后出现:

We again fleshed out what is needed in order to properly support field collapsing in a distributed environment execution, as well as the ability to get inner hits (for nested / parent child cases). We have a good idea on the type of refactoring we need in our search execution infrastructure, and hope to tackle it post 1.0.



在添加此功能之前,最好的选择是使用 multi search api所建议的 Damien进行多次搜索并以所需方式组合其结果。这意味着每个所需组构造一个搜索请求(在您的情况下,为每个搜索设置索引/类型)并解析返回的JSON排序。

关于php - 具有不同限制的Elasticsearch索引搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20420765/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com