简体   繁体   English

Solr facet计数与选择性排除

[英]Solr facet counts with selective exclude

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'. 具体来说,我有一个允许用户按'facetA'和'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. 界面清楚地表明facetA在层次结构中高于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. 我希望facetA完全持久,facetB也算是持久的,但依赖于facetA的选择。

So, the interface might react to a change to facetB with: 因此,界面可能会对facetB的更改做出反应:

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

ie none of the counts change. 即没有一个计数改变。

But it would react to a facetA change like this: 但它会对这样的facetA变化作出反应:

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

ie, the facetB counts change to reflect what is available after the facetA filter has been applied. 即,facetB计数变化以反映在应用facetA过滤器之后可用的内容。

Just doing 干得好

&facet.field={!ex=dt}fieldA&facet.field={!ex=dt}fieldB &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. 我在solr wiki中发现这方面的说明非常模糊 - 就像我甚至不知道'dt'代表什么。 Can anyone elaborate? 谁能详细说明? Can I get finer control over how counts get excluded? 我可以更好地控制如何排除计数吗?

Ok, I figured this out. 好的,我想通了。 'dt' is a user specified tag, which is set using the {!tag=*} statement, and referenced using the {!ex=} statement. 'dt'是用户指定的标记,使用{!tag = *}语句设置,并使用{!ex =}语句引用。

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. 这意味着facetA的选择(fq)不会影响facetA的计数,facetB的选择(fq)不会影响facetB的计数。

Sweet! 甜! I had almost resigned myself to sending multiple queries to get the info I needed. 我差点辞职,发送多个查询来获取我需要的信息。

Thanks. 谢谢。 This answer has saved me almost a day. 这个答案几乎让我节省了一天。

Basically I was following from example in http://wiki.apache.org/solr/SimpleFacetParameters ie 基本上我是在http://wiki.apache.org/solr/SimpleFacetParameters例子中跟随ie

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. 因此,当我有多个方面时,我仍然在两个方面使用{!tag=dt} & {!ex=dt}

Note: as rightly pointed dt is user defined tag which is used on that facet. 注意:正确指向的dt是用户定义的标签,用于该方面。 So if I use dt for both the facets, I don't get the expected response. 因此,如果我将dt用于这两个方面,我就不会得到预期的响应。

Instead => use 'dt1' & 'dt2' ... for multiple facets or as explained in above example use 'tagA' , 'tagB' .... 相反=>使用'dt1' & 'dt2' ...对于多个方面或如上例中所解释的那样使用'tagA''tagB' ....

Thanks again for your earlier post. 再次感谢您之前的帖子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM