多选Solr过滤和构面 [英] Multi-select Solr filtering and faceting

查看:105
本文介绍了多选Solr过滤和构面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的Solr服务实现构面,但是对于所看到的内容我有些困惑.我了解使用标记和排除"来忽略特定的过滤器计数,这样会发生以下情况:

I'm trying to implement facets for my Solr service, but I'm a bit confused as to what I'm seeing. I understand that Tags and Exclusions are used to ignore specific filter counts, such that something like this would happen:

[] Nike 55
[] Adidas 54
[] New Balance 32

[] Black 25
[] Blue 26
[] Red 29
[] Yellow 23
---------------

[X] Nike 55
[] Adidas 54
[] New Balance 32

[] Black 20
[] Blue 15
[] Red 13
[] Yellow 13


[X] Nike 20
[] Adidas 0
[] New Balance 0

[X] Black 20
[] Blue 15
[] Red 13
[] Yellow 13

我了解在上述情况下,我们将针对Solr查询对品牌进行过滤,并在品牌过滤器/方面上添加标记/排除,以使计数仅在品牌上保持不变.然后,我们按颜色过滤,并保持THOSE计数不变,同时让其他计数(品牌)发生变化.

I understand that in the above case, we would filter on brand for the Solr query, and pass in a tag/exclusion on the brand filter/facet for the counts to remain the same only on brand. Then, we filter by color, and keep THOSE counts the same while letting the other counts (Brand) change.

但是,这是我被卡住的地方.在较大的网站(例如Newegg,Amazon等)上,我注意到并非如此.当我通过第一个过滤器选择时,我选择的过滤器计数不会更改,而其他计数会更改.

However, here is where I get stuck. On larger sites (like Newegg, Amazon, etc...) I notice that this is NOT the case. When I select by my first filter, the filter counts I selected do not change, while the other counts do.

[X] Nike 51
[] Adidas 54
[] New Balance 32

[] Black 20
[] Blue 15
[] Red 13
[] Yellow 13

然后,当我选择第二个过滤器(与第一个过滤器不同)时,第二个过滤器的计数不变,但是第一个过滤器的计数变化的方式不会使计数清零,如下所示:

Then, when I select by the second filter (different from the first), the second filter counts don't change, but the first filter counts change in a way that doesn't zero out the counts, like so:

[X] Nike 8
[] Adidas 12
[] New Balance 5

[X] Black 20
[] Blue 15
[] Red 13
[] Yellow 13

这是怎么回事?我感觉自己发送的构面和过滤器错误地解决了问题.我只发送最近选择的过滤器的标记和排除项.这总是根据最新选择更改其他计数.但是在我概述的最后一个案例中,即使我只在寻找Black Nike鞋子,品牌过滤器也没有将其归零.我仍然对Adidas和New Balance的销售有所期待.抱歉,这篇文章太长了,但是如果没有示例,我想不出一个很好的方法来解释它.

What is happening here? I feel like I'm sending in facets and filters to solr incorrectly. I only send in the tag and exclusion for the most recently selected filter. That always changes other counts based on the most recent selection. But in the last case I outlined, the brand filter didn't zero out even though I'm only searching for Black Nike shoes; I still get prospective counts for Adidas and New Balance. Sorry this post is so long, but I couldn't think of a good way to explain it without examples.

推荐答案

您遇到的问题是,当您过滤结果时 第二次您忘记标记品牌过滤器查询.
让我们以一个例子来解决您的问题.请参考我正在使用的查询

The problem in your case is that when you filter your results second time you forget to tag you brand filter query.
Lets take an example to solve your problem.Please refer to the queries that I'm using

<lst name="brand">
<int name="Nike">6</int>
<int name="Adidas">3</int>
<int name="New Balance">1</int>
</lst>
<lst name="color">
<int name="Black">5</int>
<int name="Blue">5</int>
</lst>

用户选择耐克"

首先,从品牌"方面选择耐克".我们添加带有品牌标签的过滤器以将其从结果中排除,然后重新发出请求

User Selects "Nike"

First you select the "Nike" from Brand facet. We add the filter tagged with brand to exclude from results and re-issue the request

facet=true
&facet.field={!ex=brand}brand
&fq={!tag=brand}brand:Nike

我们得到的答复

<lst name="facet_fields">
<lst name="brand">
<int name="Nike">6</int>
<int name="Adidas">3</int>
<int name="New Balance">1</int>
</lst>
<lst name="color">
<int name="Black">3</int>
<int name="Blue">3</int>
</lst>

用户选择黑色"

现在,用户从彩色界面中选择黑色".我们添加了另一个新的带有颜色标记的过滤器查询,以将其从结果中排除.

User Selects "Black"

Now user select "Black" from color facet. We add another new filter query tagged with color to exclude it from result.

facet=true
&facet.field={!ex=brand}brand
&facet.field={!ex=color}color
&fq={!tag=brand}brand:Nike
&fq={!tag=color}color:Black

我们得到的答复

<lst name="brand">
<int name="Nike">3</int>
<int name="Adidas">2</int>
<int name="New Balance">0</int>
</lst>
<lst name="color">
<int name="Black">3</int>
<int name="Blue">3</int>
</lst>

这篇关于多选Solr过滤和构面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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