You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Varun Thacker <va...@gmail.com> on 2013/10/23 15:47:51 UTC

Multiple facet fields in "defaults" section of a Request Handler

I define 2 facets - "brand" and "category". Both have been configured in a
request handler inside "defaults"

Now a client wants to use multi select faceting. He calls the following API:

http://localhost:8983/solr/collection1/search?q=*:*&facet.field={!ex=foo}category&fq={!tag=foo}category
:"cat"

What happens in DefaultSolrParams#getParams is it picks up the facet field
from the API and discards all the other facets defined in defaults. Thus
the response does not facet on brand.

If I put the facet definitions in "invariants" then whatever is provided by
the client will be discarded.

Putting the facet definitions in "appends" cases it to facet category 2
times.

Is there a way where he does not have to provide all the facet.field
parameters in the API call?


-- 


Regards,
Varun Thacker
http://www.vthacker.in/

Re: Multiple facet fields in "defaults" section of a Request Handler

Posted by Varun Thacker <va...@gmail.com>.
I think you have explained it perfectly on how the tag exclusion makes it a
different facet field and that no logic of default/invariants/appends would
be able to solve this

I went with the custom component approach.

Although a very hacky solution could be defining this in defaults:
<str name="facet.field">{!ex=foo}category</str>
<str name="facet.field">{!ex=bar}brand</str>

And ensure whenever clients filter docs they use the following syntax:
&fq={!tag=foo}category:"cat"


On Thu, Oct 24, 2013 at 11:01 PM, Chris Hostetter
<ho...@fucit.org>wrote:

>
> : Now a client wants to use multi select faceting. He calls the following
> API:
> :
> http://localhost:8983/solr/collection1/search?q=*:*&facet.field={!ex=foo}category&fq={!tag=foo}category
> : :"cat"
>
> : Putting the facet definitions in "appends" cases it to facet category 2
> : times.
> :
> : Is there a way where he does not have to provide all the facet.field
> : parameters in the API call?
>
> What you are asking is essentially "I want to configure faceting on X and
> Y by default, but i want clients to be able to add faceting on Z and have
> that disable faceting on X while still faceting on Y"
>
> It doens't matter that X and Z are both field facets based arround the
> field name "category" -- the tag exclusion makes them completley
> different.
>
> The basic default/invariants/appends logic doesn't give you any easy
> mechanism to ignore arbitrary params like that - you could probably write
> a custom component that inspected the params and droped ones you don't
> want, but this wouldn't make sense as generalized logic in the
> FacetComponent since faceting on a field both with and w/o a tag
> expclusion at the same time is a very common use case.
>
>
>
>
> -Hoss
>



-- 


Regards,
Varun Thacker
http://www.vthacker.in/

Re: Multiple facet fields in "defaults" section of a Request Handler

Posted by Chris Hostetter <ho...@fucit.org>.
: Now a client wants to use multi select faceting. He calls the following API:
: http://localhost:8983/solr/collection1/search?q=*:*&facet.field={!ex=foo}category&fq={!tag=foo}category
: :"cat"

: Putting the facet definitions in "appends" cases it to facet category 2
: times.
: 
: Is there a way where he does not have to provide all the facet.field
: parameters in the API call?

What you are asking is essentially "I want to configure faceting on X and 
Y by default, but i want clients to be able to add faceting on Z and have 
that disable faceting on X while still faceting on Y"

It doens't matter that X and Z are both field facets based arround the 
field name "category" -- the tag exclusion makes them completley 
different.

The basic default/invariants/appends logic doesn't give you any easy 
mechanism to ignore arbitrary params like that - you could probably write 
a custom component that inspected the params and droped ones you don't 
want, but this wouldn't make sense as generalized logic in the 
FacetComponent since faceting on a field both with and w/o a tag 
expclusion at the same time is a very common use case.




-Hoss