John,

I just want to make sure I understand correctly. Replace, fq with facet.query?

So then the resultant query goes from:
q=*:*&facet=on&facet.field=Communities&fq=Communities:"BANFF TRAIL - BNF"

to:
q=*:*&facet=on&facet.field=Communities&facet.query="BANFF TRAIL - BNF"


If that's correct, then this does not resolve the issue. I still get 2 values 
under Communities facet.

Harinder

-----Original Message-----
From: John Blythe [mailto:johnbly...@gmail.com] 
Sent: Tuesday, September 25, 2018 2:50 PM
To: solr-user@lucene.apache.org
Subject: [EXT] Re: Faceting with a multi valued field

you can update your filter query to be a facet query, this will apply the query 
to the resulting facet set instead of the Communities field itself.

--
John Blythe


On Tue, Sep 25, 2018 at 4:15 PM Hanjan, Harinder <harinder.han...@calgary.ca>
wrote:

> Hello!
>
> I am doing faceting on a field which has multiple values and it's 
> yielding expected but undesireable results. I need different behaviour 
> but not sure how to formulate a query for it. Here is my current setup.
>
> ===== Data Set =====
>   {
> "Communities":["BANFF TRAIL - BNF", "PARKDALE - PKD"], "Document 
> Type":"Engagement - What We Heard Report", "Navigation":"Livelink", 
> "SolrId":"https://urldefense.proofpoint.com/v2/url?u=http-3A__thesimpsons.com_one&d=DwIBaQ&c=jdm1Hby_BzoqwoYzPsUCHSCnNps9LuidNkyKDuvdq3M&r=N30IrhmaeKKhVHu13d-HO9gO9CysWnvGGoKrSNEuM3U&m=PX7TJqsA8tYgbN7HmkGd0GNzotXPc3hcoc9xRvmOiXI&s=GMTgF731T72VIryx_v7VD5f_oBlbrzXYAB1UEBQMOOc&e=";
>   }
>   {
> "Communities":["BANFF TRAIL - BNF", "PARKDALE - PKD"], "Document 
> Type":"Engagement - What We Heard Report", "Navigation":"Livelink", 
> "Id":"https://urldefense.proofpoint.com/v2/url?u=http-3A__thesimpsons.com_two&d=DwIBaQ&c=jdm1Hby_BzoqwoYzPsUCHSCnNps9LuidNkyKDuvdq3M&r=N30IrhmaeKKhVHu13d-HO9gO9CysWnvGGoKrSNEuM3U&m=PX7TJqsA8tYgbN7HmkGd0GNzotXPc3hcoc9xRvmOiXI&s=FN6T49z8wjc_mRdXnVHgcdZBcZB6O_InSyUzxaxxiM0&e=";
>   }
>   {
> "Communities":["SUNALTA - SNA"],
> "Document Type":"Engagement - What We Heard Report", 
> "Navigation":"Livelink", 
> "Id":"https://urldefense.proofpoint.com/v2/url?u=http-3A__thesimpsons.com_three&d=DwIBaQ&c=jdm1Hby_BzoqwoYzPsUCHSCnNps9LuidNkyKDuvdq3M&r=N30IrhmaeKKhVHu13d-HO9gO9CysWnvGGoKrSNEuM3U&m=PX7TJqsA8tYgbN7HmkGd0GNzotXPc3hcoc9xRvmOiXI&s=HEJFyAhHIn5T-riqVVMR011KXAn38lZUDyRQ-ljC-qA&e=";
>   }
>
> ===== Query I run now =====
>
> https://urldefense.proofpoint.com/v2/url?u=http-3A__localhost-3A8984_s
> olr_everything_select-3Fq-3D-2A-3A-2A-26facet-3Don-26facet.field-3DCom
> munities-26fq-3DCommunities-3A-2522BANFF&d=DwIBaQ&c=jdm1Hby_BzoqwoYzPs
> UCHSCnNps9LuidNkyKDuvdq3M&r=N30IrhmaeKKhVHu13d-HO9gO9CysWnvGGoKrSNEuM3
> U&m=PX7TJqsA8tYgbN7HmkGd0GNzotXPc3hcoc9xRvmOiXI&s=Cx6EubqN_-ocYrZA6jsJ
> TGzodPqUPVu78eY1iMB_0L8&e=
> TRAIL - BNF"
>
>
> ===== Results I get now =====
> {
>   ...
>   "facet_counts":{
>     "facet_queries":{},
>     "facet_fields":{
>       "Communities":[
>         "BANFF TRAIL - BNF",2,
>         "PARKDALE - PKD",2,
>         "SUNALTA - SNA",0]},
>    ...
>
> Notice that the Communities facet has 2 non zero results. I understand 
> this is because I'm using fq to get only documents which contain BANFF 
> TRAIL but those documents also contain PARKDALE.
>
> Now, I am using facets to drive navigation on my page. The business 
> case is that user can select a community to get documents pertaining 
> to that specific community only. This works with the query I have 
> above. However, the facets results also contain other communities 
> which then get displayed to the user. For example, with the query 
> above, user will see both BANFF TRAIL and PARKDALE as selected values 
> even though user only selected BANFF TRAIL. It's worthwhile noting 
> that I have no control over the data being sent to Solr and can't change it.
>
> How can I formulate a query to ensure that when user selects BANFF 
> TRAIL, only BANFF TRAIL is returned under Solr facets?
>
> Thanks!
> Harinder
>
> ________________________________
> NOTICE -
> This communication is intended ONLY for the use of the person or 
> entity named above and may contain information that is confidential or 
> legally privileged. If you are not the intended recipient named above 
> or a person responsible for delivering messages or communications to 
> the intended recipient, YOU ARE HEREBY NOTIFIED that any use, 
> distribution, or copying of this communication or any of the 
> information contained in it is strictly prohibited. If you have 
> received this communication in error, please notify us immediately by 
> telephone and then destroy or delete this communication, or return it 
> to us by mail if requested by us. The City of Calgary thanks you for your 
> attention and co-operation.
>

Reply via email to