Thanks for your reply, Shawn.

I think multi-select faceting does the opposite of what I want. I want the
facet to include the filters.

Example:

The following 8 documents are the only ones in my Solr core:

[
  {"id": "1", "hierarchy": ["1", "16", "169"], "interests": ["soccer",
"futbol"]},
  {"id": "2", "hierarchy": ["1", "16", "162"], "interests": ["cricket",
"futbol"]},
  {"id": "3", "hierarchy": ["1", "14", "141"], "interests": ["hockey",
"soccer"]},
  {"id": "4", "hierarchy": ["1", "16", "162"], "interests": ["hockey",
"soccer", "tennis"]},
  {"id": "5", "hierarchy": ["1", "14", "142"], "interests": ["badminton"]},
  {"id": "6", "hierarchy": ["1", "14", "147"], "interests": ["soccer"]},
  {"id": "7", "hierarchy": ["1", "16", "168"], "interests": ["hockey",
"soccer", "tennis"]},
  {"id": "8", "hierarchy": ["1", "14", "140"], "interests": ["badminton"]}
]

As you can see, hierarchy and interests are both multi-valued string fields.

I want pivot facet counts for the two fields: hierarchy and interests, but
filtered for only two values of interests field: hockey, soccer.

The query I am running is:

/select
?wt=json
&rows=0
&q=interests:(hockey soccer)
&facet=true
&facet.pivot=hierarchy,interests

This gives the following result for the pivot facets:

"facet_pivot": {
    "hierarchy,interests": [
    {
      "field": "hierarchy",
      "value": "1",
      "count": 5,
      "pivot": [
        {"field": "interests", "value": "soccer", "count": 5},
        {"field": "interests", "value": "hockey", "count": 3},
        {"field": "interests", "value": "tennis", "count": 2},
        {"field": "interests", "value": "futbol", "count": 1}
      ]
    },
    {
      "field": "hierarchy",
      "value": "16",
      "count": 3,
      "pivot": [
        {"field": "interests", "value": "soccer", "count": 3},
        {"field": "interests", "value": "hockey", "count": 2},
        {"field": "interests", "value": "tennis", "count": 2},
        {"field": "interests", "value": "futbol", "count": 1}
      ]
    },
    ...
    ]
}

The counts for hockey and soccer are correct. But I am also getting the
facet counts for other values of interests (like tennis, futbol, etc.,)
since these values match the query. I understand why this is happening.
This is why I said I want to do something like
https://lucene.apache.org/solr/guide/6_6/faceting.html#Faceting-Limitingfacetwithcertainterms
for facet pivots. Is there a way to do that?

Thanks.



On Wed, Dec 20, 2017 at 1:07 PM, Shawn Heisey <apa...@elyograg.org> wrote:

> On 12/20/2017 1:31 PM, Arun Rangarajan wrote:
> > Sorry to bother you again on this. Is there no way in Solr to filter
> pivot
> > facets?
> > [Or did I attract the wrath of the group by posting the question first on
> > StackOverflow? :-)]
>
> StackOverflow and this list are pretty much unaware of each other unless
> specific mention is made.  I don't care whether you ask on SO or not, or
> which one you ask first.
>
> You haven't provided actual output that you're seeing.  Can you provide
> actual response output from your queries and describe what you'd rather
> see instead?  With that information, we might be able to offer some ideas.
>
> In general, facets should never count documents that are not in the
> search results.
>
> Multi-select faceting offers a way to change that general behavior,
> though -- tagging specific fq parameters and asking the facet to exclude
> those filters.
>
> https://wiki.apache.org/solr/SimpleFacetParameters#Tagging_
> and_excluding_Filters
>
> Thanks,
> Shawn
>
>

Reply via email to