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 "atuldj.jadhav" <at...@gmail.com> on 2014/04/24 00:22:35 UTC

Selectively hiding SOLR facets.

Hi team.

Please help me address one problem I am facing in SOLR faceting.
I have two websites (for countries Belgium & US) on each of these websites I
have a managers details page which is served from a common SOLR index.

I have indexed feed xml in SOLR.
<add>
<doc> 
	<field name="id">1</field>
	<field name="language">French</field>
      	<field name="country">BE</field>
     	<field name="author">Chris</field>
</doc>	
<doc> 
	<field name="id">2</field>
	<field name="language">Dutch</field>
         <field name="country">UK</field>
         <field name="author">Jeff</field>
</doc>	
<doc> 
	<field name="id">3</field>
	<field name="language">Spanish</field>
       	<field name="country">USA</field>
       	<field name="author">Jacek</field>
</doc>	
<doc> 
	<field name="id">4</field>
	<field name="language">English</field>
  <field name="country">USA</field>
  <field name="author">Dave</field>
</doc>	
</add>

On US site I want to show managers and language specific to that particular
country only with language facets. However below query gives me Belgium
websites language facets as well 

http://solr:8080/select?q=country:”USA”&facet=on&facet.field=”language”
language
English   [1]
Spanish  [1]
French   [0]
Dutch     [0]

*I cannot use facet.mincount=1 approach because when English language facet
is selected business expects Spanish to be shown with 0 count.*

So I want to selectively hide certain facets… i.e. French and Dutch…

Can this be achieved through SOLR query/configuration?



--
View this message in context: http://lucene.472066.n3.nabble.com/Selectively-hiding-SOLR-facets-tp4132770.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Selectively hiding SOLR facets.

Posted by Alexandre Rafalovitch <ar...@gmail.com>.
How would you know it if you did this manually? Solr does not know
that Dutch is not valid for USA. You need to give it some sort of
signal.

One way could be to have a dynamic field for a facet which includes
country name. So, you have language_USA, language_Belgium, etc. Then,
when you do country:USA, you also do facet count against language_USA.

You could even get super fancy with field aliases and other tricks,
though this may get messy if you do need it for each country.

Regards,
   Alex.
Personal website: http://www.outerthoughts.com/
Current project: http://www.solr-start.com/ - Accelerating your Solr proficiency


On Tue, Apr 29, 2014 at 9:56 AM, atuldj.jadhav <at...@gmail.com> wrote:
> Yes, but with my query *country:"USA" * it is returning me languages
> belonging to countries other than USA.
>
> Is there any way I can avoid such languages appearing in my facet filters?
>
>
>
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Selectively-hiding-SOLR-facets-tp4132770p4133638.html
> Sent from the Solr - User mailing list archive at Nabble.com.

Re: Selectively hiding SOLR facets.

Posted by "Iker Mtnz. Apellaniz" <mi...@gmail.com>.
You could use facet.mincount parameter. default value is 0, setting it as N
would require a minimum appearance on the result Set

Iker


2014-04-29 4:56 GMT+02:00 atuldj.jadhav <at...@gmail.com>:

> Yes, but with my query *country:"USA" * it is returning me languages
> belonging to countries other than USA.
>
> Is there any way I can avoid such languages appearing in my facet filters?
>
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Selectively-hiding-SOLR-facets-tp4132770p4133638.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>



-- 
/** @author imartinez*/
Person me = *new* Developer();
me.setName(*"Iker Mtz de Apellaniz Anzuola"*);
me.setTwit("@mitxino77 <https://twitter.com/mitxino77>");
me.setLocations({"St Cugat, Barcelona", "Kanpezu, Euskadi", "*, World"]});
me.setSkills({*SoftwareDeveloper, Curious, AmateurCook*});
*return* me;

Re: Selectively hiding SOLR facets.

Posted by "atuldj.jadhav" <at...@gmail.com>.
Yes, but with my query *country:"USA" * it is returning me languages
belonging to countries other than USA.
 
Is there any way I can avoid such languages appearing in my facet filters?




--
View this message in context: http://lucene.472066.n3.nabble.com/Selectively-hiding-SOLR-facets-tp4132770p4133638.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Selectively hiding SOLR facets.

Posted by bbi123 <bb...@gmail.com>.
Not sure if I understand your question.

The language field has both spanish and english for the country='USA' and
SOLR is returning all the available facets for country="USA"

<doc>
<str name="id">3</str>
<str name="language">Spanish</str>
<str name="country">USA</str>
<str name="author">Jacek</str>
<long name="_version_">1466216353231798272</long>
</doc>
<doc>
<str name="id">4</str>
<str name="language">English</str>
<str name="country">USA</str>
<str name="author">Dave</str>
<long name="_version_">1466216353231798273</long>
</doc>



--
View this message in context: http://lucene.472066.n3.nabble.com/Selectively-hiding-SOLR-facets-tp4132770p4132774.html
Sent from the Solr - User mailing list archive at Nabble.com.