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 Allistair Crossley <al...@roxxor.co.uk> on 2010/09/29 15:37:29 UTC

Missing facet values for zero counts

Hello list,

I am implementing a directory using Solr. The user is able to search with a free-text query or 2 filters (provided as pick-lists) for country. A directory entry only has one country.

I am using Solr facets for country and I use the facet counts generated initially by a *:* search to generate my pick-list.

This is working fairly well but there are a couple of issues I am facing.

Specifically the countries pick-list does not contain ALL possible countries. It only contains those that have been indexed against a document. 

I have looked at facet.missing but I cannot see how this will work - if no documents have a country of Sweden, then how would Solr know to generate a missing total of zero for Sweden - it's never heard of it.

I feel I am missing something - is there a way by which you tell Solr all possible countries rather than relying on counts generated from the index? 

The countries in question reside in a database table belonging to our application.

Thanks, Allistair

Re: Missing facet values for zero counts

Posted by Allistair Crossley <al...@roxxor.co.uk>.
Hi,

For us this is a usability concern. You either don't show Sweden in a pick-list called Country and some users go away thinking you don't *ever* support Sweden (not true). OR you allow a user to execute an empty result search - but at least they know you do support Sweden.

It is we believe undesirable for a pick-list to change from day to day as the index changes - we have a category pick-list also that acts the same. One day a user could see Productions, the next day nothing. Regular users would see this as odd.

We believe that usability dictates we show all possible values and add a zero after to prevent the user executing searches but at least they see the possibilities. The best of both worlds we hope.

I have solved this using earlier suggestions of merging a database list query with the Solr facet counts. I like your idea though - good thinking but the way I've done is working great also :)

Thanks and best wishes, Allistair

On 29 Sep 2010, at 14:08, kenf_nc wrote:

> 
> I don't understand why you would want to show Sweden if it isn't in the
> index, what will your UI do if the user selects Sweden?
> 
> However, one way to handle this would be to make a second document type.
> Have a field called type or some such, and make the new document type be
> 'dummy' or 'system' or something like that. You can put documents in here
> with fields for any pick-lists you want to facet on and include all possible
> values from your database.
> 
> Do your facets on either just this doc, or all docs, either way should work.
> However on your search queries always include   fq=-type:system
> basically exclude all documents of type system from all your searches. 
> Messy, but should do what you want.
> -- 
> View this message in context: http://lucene.472066.n3.nabble.com/Missing-facet-values-for-zero-counts-tp1602276p1603893.html
> Sent from the Solr - User mailing list archive at Nabble.com.


Re: Missing facet values for zero counts

Posted by kenf_nc <ke...@realestate.com>.
I don't understand why you would want to show Sweden if it isn't in the
index, what will your UI do if the user selects Sweden?

However, one way to handle this would be to make a second document type.
Have a field called type or some such, and make the new document type be
'dummy' or 'system' or something like that. You can put documents in here
with fields for any pick-lists you want to facet on and include all possible
values from your database.

Do your facets on either just this doc, or all docs, either way should work.
However on your search queries always include   fq=-type:system
basically exclude all documents of type system from all your searches. 
Messy, but should do what you want.
-- 
View this message in context: http://lucene.472066.n3.nabble.com/Missing-facet-values-for-zero-counts-tp1602276p1603893.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Missing facet values for zero counts

Posted by Chantal Ackermann <ch...@btelligent.de>.
Hi Allistair,


On Wed, 2010-09-29 at 15:37 +0200, Allistair Crossley wrote:
> Hello list,
> 
> I am implementing a directory using Solr. The user is able to search with a free-text query or 2 filters (provided as pick-lists) for country. A directory entry only has one country.
> 
> I am using Solr facets for country and I use the facet counts generated initially by a *:* search to generate my pick-list.
> 
> This is working fairly well but there are a couple of issues I am facing.
> 
> Specifically the countries pick-list does not contain ALL possible countries. It only contains those that have been indexed against a document. 
> 
> I have looked at facet.missing but I cannot see how this will work - if no documents have a country of Sweden, then how would Solr know to generate a missing total of zero for Sweden - it's never heard of it.
> 
> I feel I am missing something - is there a way by which you tell Solr all possible countries rather than relying on counts generated from the index? 
> 

I don't think you are missing anything. Instead, you've described it
very well: how should SOLR know of something that never made it into the
index?

Why not just state in the interface that for all missing countries (and
deduce that from the facets and the list retrieved from the database),
there are no hits. You can list those countries separately (or even add
them to the facets after processing solr's result).

If you do want to have them in the index, you'd have to add them by
adding empty documents. But you might get into trouble with required
fields etc. And you will change the statistics of the fields.


Chantal




Re: Missing facet values for zero counts

Posted by Allistair Crossley <al...@roxxor.co.uk>.
OK good to know I'm not going bonkers :)

Cheers

On Sep 29, 2010, at 9:45 AM, Luke Crouch wrote:

> We had to do the same thing - we draw our facet navigation links by looping
> over the full result set from our database, and then we add the facet counts
> and draw the link url's using the solr data.
> 
> -L
> 
> On Wed, Sep 29, 2010 at 8:42 AM, Markus Jelsma <ma...@buyways.nl>wrote:
> 
>> I'm afraid you'd have to add the missing countries in your application. If
>> it's not in the index, it will not be returned. You last question is
>> possible, the facet.query parameter allows you to rely on other conditions
>> to generate a facet count. But if the missing countries are not in the
>> index, you cannot query against them.
>> 
>> -----Original message-----
>> From: Allistair Crossley <al...@roxxor.co.uk>
>> Sent: Wed 29-09-2010 15:38
>> To: solr-user@lucene.apache.org;
>> Subject: Missing facet values for zero counts
>> 
>> Hello list,
>> 
>> I am implementing a directory using Solr. The user is able to search with a
>> free-text query or 2 filters (provided as pick-lists) for country. A
>> directory entry only has one country.
>> 
>> I am using Solr facets for country and I use the facet counts generated
>> initially by a *:* search to generate my pick-list.
>> 
>> This is working fairly well but there are a couple of issues I am facing.
>> 
>> Specifically the countries pick-list does not contain ALL possible
>> countries. It only contains those that have been indexed against a document.
>> 
>> I have looked at facet.missing but I cannot see how this will work - if no
>> documents have a country of Sweden, then how would Solr know to generate a
>> missing total of zero for Sweden - it's never heard of it.
>> 
>> I feel I am missing something - is there a way by which you tell Solr all
>> possible countries rather than relying on counts generated from the index?
>> 
>> The countries in question reside in a database table belonging to our
>> application.
>> 
>> Thanks, Allistair
>> 


Re: Missing facet values for zero counts

Posted by Luke Crouch <lc...@geek.net>.
We had to do the same thing - we draw our facet navigation links by looping
over the full result set from our database, and then we add the facet counts
and draw the link url's using the solr data.

-L

On Wed, Sep 29, 2010 at 8:42 AM, Markus Jelsma <ma...@buyways.nl>wrote:

> I'm afraid you'd have to add the missing countries in your application. If
> it's not in the index, it will not be returned. You last question is
> possible, the facet.query parameter allows you to rely on other conditions
> to generate a facet count. But if the missing countries are not in the
> index, you cannot query against them.
>
> -----Original message-----
> From: Allistair Crossley <al...@roxxor.co.uk>
> Sent: Wed 29-09-2010 15:38
> To: solr-user@lucene.apache.org;
> Subject: Missing facet values for zero counts
>
> Hello list,
>
> I am implementing a directory using Solr. The user is able to search with a
> free-text query or 2 filters (provided as pick-lists) for country. A
> directory entry only has one country.
>
> I am using Solr facets for country and I use the facet counts generated
> initially by a *:* search to generate my pick-list.
>
> This is working fairly well but there are a couple of issues I am facing.
>
> Specifically the countries pick-list does not contain ALL possible
> countries. It only contains those that have been indexed against a document.
>
> I have looked at facet.missing but I cannot see how this will work - if no
> documents have a country of Sweden, then how would Solr know to generate a
> missing total of zero for Sweden - it's never heard of it.
>
> I feel I am missing something - is there a way by which you tell Solr all
> possible countries rather than relying on counts generated from the index?
>
> The countries in question reside in a database table belonging to our
> application.
>
> Thanks, Allistair
>

RE: Missing facet values for zero counts

Posted by Markus Jelsma <ma...@buyways.nl>.
I'm afraid you'd have to add the missing countries in your application. If it's not in the index, it will not be returned. You last question is possible, the facet.query parameter allows you to rely on other conditions to generate a facet count. But if the missing countries are not in the index, you cannot query against them. 
 
-----Original message-----
From: Allistair Crossley <al...@roxxor.co.uk>
Sent: Wed 29-09-2010 15:38
To: solr-user@lucene.apache.org; 
Subject: Missing facet values for zero counts

Hello list,

I am implementing a directory using Solr. The user is able to search with a free-text query or 2 filters (provided as pick-lists) for country. A directory entry only has one country.

I am using Solr facets for country and I use the facet counts generated initially by a *:* search to generate my pick-list.

This is working fairly well but there are a couple of issues I am facing.

Specifically the countries pick-list does not contain ALL possible countries. It only contains those that have been indexed against a document. 

I have looked at facet.missing but I cannot see how this will work - if no documents have a country of Sweden, then how would Solr know to generate a missing total of zero for Sweden - it's never heard of it.

I feel I am missing something - is there a way by which you tell Solr all possible countries rather than relying on counts generated from the index? 

The countries in question reside in a database table belonging to our application.

Thanks, Allistair