有效的计算方法*方位计数*弹性搜索 [英] Efficient way to compute *Facet Counts* in Elastic Search

查看:162
本文介绍了有效的计算方法*方位计数*弹性搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想计算一个方面查询界面的方面的计数,但是我想我缺少一些东西,因为我无法使用facet过滤器获取我需要的数字。

I want to compute facet counts for a facet query UI but I think I am missing something as I am unable to get the numbers I need using facet filters.

这是一个例子。给出两个方面,每个方面有三个可能的术语:

Here's an example. Given two facets with three possible terms in each facet:

Colors: {red, yellow, blue}
Notes: {do, re, mi}

当我进行搜索时,每个方面的每个术语的计数不要考虑在其他方面设置的过滤器。

When I do a search, the counts for each term in a facet do not take into account the filters set in the other facet.

说明:

[ ] All colors (18)
 [x] Red (10)
 [ ] Green (5)
 [ ] Blue (3)

[ ] All notes (18)
 [ ] Do (5)
 [x] Re (7)
 [ ] Mi (6)

请注意,每个方面的总计与查询的匹配总数相等,如同没有设置过滤器一样。

Note that the totals within each facet sum to the total number of hits for the query as though no filters are set.

我想要的行为是Notes面中的数字将考虑到Colors面中的过滤器,反之亦然。也就是说,笔记条款的数字应该总和为10(与红色过滤器匹配)而不是18.

The behaviour I want is for the numbers in the Notes facet to take into account the filter in the Colors facet and vice versa. That is, the numbers for the note terms should sum to 10 (to match the red filter), not 18.

有趣的是,文档中的示例截图使用示例来自Linked In,其中实际显示了我想要的行为。

Interestingly, the example screenshot in the docs uses an example from Linked In which actually demonstrates the behavior that I want.

http://www.elasticsearch.org/guide/reference/api/search/facets/

我是通过在每个方面(ugh)为每个术语手动重新提交查询一次就能获得所需结果,但我想知道是否有办法通过更改查询来获得与LinkedIn同样的行为。

I am able to get the result I want by manually resubmitting the query once for each term in each facet (ugh) but I wonder if there is a way to get the same behaviour as LinkedIn out of the box by changing my query.

推荐答案

我发现这个工作的唯一方法是通过以下逻辑为任何多选择方面:

The only way I've found this to work is via the following logic for any multi-select facet:

每当用户从小平面(向下钻取)中选择一个值时,您可以向所有构面(通过facet_filter)添加一个相应的过滤器,除之外,选择wa以及顶级过滤器过滤查询结果。

Whenever the user selects a value from a facet ("drills down") you add a corresponding filter to all facets (via facet_filter) except the facet that the selection was done in, as well as to the top-level filter to filter the query results.

换句话说,给定3个多选方面,A,B& C:

In other words, given 3 multi-select facets, A, B & C:


  • 从A =>添加过滤器到顶级 过滤器 以及B面和C面的 facet_filter

  • 从B =>添加过滤器到顶级 过滤器中的值 以及A& A的 facet_filter C。

  • ...等等

  • Select value from A => Add filter to top-level filter as well as to the facet_filter of facet B and C.
  • Select value from B => Add filter to top-level filter as well as to the facet_filter of A & C.
  • ... and so on

顶级过滤器始终将过滤所有选择,而每个独立facet包含facet_filters根据 其他 方面的选择。

The top-level filter always combines the filters for all selections, whereas each individual facet contains facet_filters according to the selection in the other facets.

这篇关于有效的计算方法*方位计数*弹性搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆