Solr 方面计数与选择性排除

发布于 2024-11-27 13:19:28 字数 920 浏览 1 评论 0原文

我不确定这是否可行,但我希望能够比仅仅包含和排除更严格地控​​制为构面返回的计数。

具体来说,我有一个界面,允许用户按“facetA”和“facetB”进行过滤。看起来有点像这样的

  Filter by
    - facetA:    article (20), image (6), activity (14)
    - facetB:    cats (23), dogs(12), hedgehogs(5)

界面,清楚地表明facetA在层次结构中比facetB更高。 我希望facetA计数是完全持久的,facetB计数也是持久的,但取决于facetA的选择。

因此,接口可能会对facetB 的更改做出反应:

  Filter by
    - facetA:    article (20), image (6), activity (14)
    - facetB:    cats (23), dogs(12), hedgehogs(5)

即没有任何计数发生变化。

但它会对facetA 的变化做出如下反应:

  Filter by
    - facetA:    article (20), image (6), activity (14)
    - facetB:    cats (15), dogs(4), hedgehogs(1)

即,facetB 计数发生变化以反映应用facetA 过滤器后可用的内容。

仅执行

&facet.field={!ex=dt}fieldA&facet.field={!ex=dt}fieldB

并不能达到我想要的效果,但已经很接近了。我发现 solr wiki 中的说明非常模糊 - 就像我什至不知道“dt”代表什么。谁能详细说明一下吗?我可以更好地控制如何排除计数吗?

I'm not sure if this is possible, but I'd like to be able to control the counts returned for facets more closely than just include and exclude.

Specifically, I have an interface that allows users to filter by 'facetA' and 'facetB'. It looks a little like this

  Filter by
    - facetA:    article (20), image (6), activity (14)
    - facetB:    cats (23), dogs(12), hedgehogs(5)

The interface makes it clear that facetA is higher in the hierarchy than facetB.
I'd like the facetA counts to be completely persistent, and the facetB counts to also be persistent, but to depend on the selection of facetA.

So, the interface might react to a change to facetB with:

  Filter by
    - facetA:    article (20), image (6), activity (14)
    - facetB:    cats (23), dogs(12), hedgehogs(5)

i.e. none of the counts change.

But it would react to a facetA change like this:

  Filter by
    - facetA:    article (20), image (6), activity (14)
    - facetB:    cats (15), dogs(4), hedgehogs(1)

i.e, the facetB counts change to reflect what is available after the facetA filter has been applied.

Just doing

&facet.field={!ex=dt}fieldA&facet.field={!ex=dt}fieldB

doesn't achieve what I want it to, but it is close. I find the instructions on this in the solr wiki are very vague - like I don't even know what the 'dt' stands for. Can anyone elaborate? Can I get finer control over how counts get excluded?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

痴情换悲伤 2024-12-04 13:19:28

好吧,我明白了。 'dt' 是用户指定的标记,它使用 {!tag=*} 语句设置,并使用 {!ex=} 语句引用。

因此,如果我将以下内容添加到查询中,上面的示例就得到修复:

&fq={!tag=tagA}fieldA:facetASelection
&fq={!tag=tagB}fieldB:facetBSelection
&facet=true
&facet.field={!ex=tagA}fieldA
&facet.field={!ex=tagB}fieldB

这意味着facetA 的选择 (fq) 不会影响facetA 的计数,并且facetB 的选择(fq) 不会影响facetB 的计数面B.

甜的!我几乎已经放弃发送多个查询来获取我需要的信息。

Ok, I figured this out. 'dt' is a user specified tag, which is set using the {!tag=*} statement, and referenced using the {!ex=} statement.

So, the example above is fixed if I add the following to my query:

&fq={!tag=tagA}fieldA:facetASelection
&fq={!tag=tagB}fieldB:facetBSelection
&facet=true
&facet.field={!ex=tagA}fieldA
&facet.field={!ex=tagB}fieldB

This means that the selection (fq) for facetA doesn't effect the counts for facetA, and the selection (fq) of facetB doesn't effect the counts for facetB.

Sweet! I had almost resigned myself to sending multiple queries to get the info I needed.

浅忆 2024-12-04 13:19:28

谢谢。这个答案为我节省了几乎一天的时间。

基本上我是按照 http://wiki.apache.org/solr/SimpleFacetParameters 中的示例进行操作的,即

q=mainquery&fq=status:public&fq={!tag=dt}doctype:pdf&facet=on&facet.field={!ex=dt}doctype

当我有多个方面时,我仍然使用 {!tag=dt} &两个面上的 {!ex=dt}

注意:正确指出的 dt 是用户定义的标签,用于该方面。
因此,如果我对两个方面都使用 dt,我不会得到预期的响应。

相反=>使用 'dt1' & 'dt2' ...对于多个方面或如上面示例中所述,使用 'tagA''tagB'....

再次感谢您之前的帮助邮政。

Thanks. This answer has saved me almost a day.

Basically I was following from example in http://wiki.apache.org/solr/SimpleFacetParameters i.e.

q=mainquery&fq=status:public&fq={!tag=dt}doctype:pdf&facet=on&facet.field={!ex=dt}doctype

So when I have multiple facets, I still used {!tag=dt} & {!ex=dt} on both the facets.

Note: as rightly pointed dt is user defined tag which is used on that facet.
So if I use dt for both the facets, I don't get the expected response.

Instead => use 'dt1' & 'dt2' ... for multiple facets or as explained in above example use 'tagA', 'tagB'....

Thanks again for your earlier post.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文