What specifically do you control? Just keyword (and "Communities:" part is locked?) or anything after q= or anything that allows multiple variables?
Because if you could isolate search value, you could use for example facet.prefix, set in solrconfig as a default parameter and populated from the same variable as the Communities search. You may also want to set facet.mincount=1 in solrconfig.xml to avoid 0-value facets in general: https://lucene.apache.org/solr/guide/7_4/faceting.html Regards, Alex. On 25 September 2018 at 16:50, John Blythe <johnbly...@gmail.com> wrote: > 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":"http://thesimpsons.com/one" >> } >> { >> "Communities":["BANFF TRAIL - BNF", "PARKDALE - PKD"], >> "Document Type":"Engagement - What We Heard Report", >> "Navigation":"Livelink", >> "Id":"http://thesimpsons.com/two" >> } >> { >> "Communities":["SUNALTA - SNA"], >> "Document Type":"Engagement - What We Heard Report", >> "Navigation":"Livelink", >> "Id":"http://thesimpsons.com/three" >> } >> >> ===== Query I run now ===== >> >> http://localhost:8984/solr/everything/select?q=*:*&facet=on&facet.field=Communities&fq=Communities:"BANFF >> 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. >>