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 Dotan Cohen <do...@gmail.com> on 2013/06/05 14:27:17 UTC

Receiving unexpected Faceting results.

Consider the following Solr query:
select?q=*:*&fq=tags:dotan-*&facet=true&facet.field=tags&rows=0

The 'tags' field is a multivalue field. I would expect the previous
query to return only tags that begin with the string 'dotan-' such as:
dotan-home
dotan-work
...but not strings which do not begin with (or even contain) the
string in question.

However, I am getting these results:
<lst name="discoapi_tags">
    <int name="dotan-home">14</int>
    <int name="dotan-work">13</int>
    <int name="beer">0</int>
    <int name="beatles">0</int>
</lst>

It _may_ be that the 'beer' and 'beatles' tags were once attached to
the same documents as are attached the 'dotan-home' and/or
'dotan-work'. I've done a bit of experimenting on this Solr install,
so I cannot be sure. However, considering that they are in fact 0
results for those two, I would not expect them to show up at all, even
if they ever were attached to (i.e. once a value in the multiValue
field) any of the results that match the filter query.

So, the questions are:
1) How can I check if ever the multiValue fields for a particular
document (given its uniqueKey id) ever contains a specific value.
Alternatively, how can I see all the values that the document ever had
for the field. I don't expect this to actually be possible, but I ask
if it is, i.e. by examining certain aspects of the Solr index with a
text editor.

2) If those spurious results are appearing does that mean necessarily
that those values for the multivalued field were in fact once in the
multivalued field for documents matching the filter query? Thus, the
answer to the previous question would be to simply run a query for the
id of the document in question, and facet on the multivalued field
with a large limit.

3) How to have Solr return only those faceting values for the field
that in fact begin with 'dotan-', even if a document has other tags
such as 'beatles'?

4) How to have Solr return only those faceting values which are larger than 0?

Thank you!

--
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com

Re: Receiving unexpected Faceting results.

Posted by Dotan Cohen <do...@gmail.com>.
On Wed, Jun 5, 2013 at 3:41 PM, Brendan Grainger
<br...@gmail.com> wrote:
> Hi Dotan,
>
> I think all you need to do is add:
>
> facet.mincount=1
>
> i.e.
>
> select?q=*:*&fq=tags:dotan-*&facet=true&facet.field=tags&
> rows=0&facet.mincount=1
>
> Note that you can do it per field as well:
>
> select?q=*:*&fq=tags:dotan-*&facet=true&facet.field=tags&
> rows=0&f.tags.facet.mincount=1
>
> http://wiki.apache.org/solr/SimpleFacetParameters#facet.mincount
>

Thanks, Brendan. I will review the available Facet Parameters, which I
really should have thought to do before posting as it is already
bookmarked!

Re: Receiving unexpected Faceting results.

Posted by Brendan Grainger <br...@gmail.com>.
Hi Dotan,

I think all you need to do is add:

facet.mincount=1

i.e.

select?q=*:*&fq=tags:dotan-*&facet=true&facet.field=tags&
rows=0&facet.mincount=1

Note that you can do it per field as well:

select?q=*:*&fq=tags:dotan-*&facet=true&facet.field=tags&
rows=0&f.tags.facet.mincount=1

http://wiki.apache.org/solr/SimpleFacetParameters#facet.mincount




On Wed, Jun 5, 2013 at 8:27 AM, Dotan Cohen <do...@gmail.com> wrote:

> Consider the following Solr query:
> select?q=*:*&fq=tags:dotan-*&facet=true&facet.field=tags&rows=0
>
> The 'tags' field is a multivalue field. I would expect the previous
> query to return only tags that begin with the string 'dotan-' such as:
> dotan-home
> dotan-work
> ...but not strings which do not begin with (or even contain) the
> string in question.
>
> However, I am getting these results:
> <lst name="discoapi_tags">
>     <int name="dotan-home">14</int>
>     <int name="dotan-work">13</int>
>     <int name="beer">0</int>
>     <int name="beatles">0</int>
> </lst>
>
> It _may_ be that the 'beer' and 'beatles' tags were once attached to
> the same documents as are attached the 'dotan-home' and/or
> 'dotan-work'. I've done a bit of experimenting on this Solr install,
> so I cannot be sure. However, considering that they are in fact 0
> results for those two, I would not expect them to show up at all, even
> if they ever were attached to (i.e. once a value in the multiValue
> field) any of the results that match the filter query.
>
> So, the questions are:
> 1) How can I check if ever the multiValue fields for a particular
> document (given its uniqueKey id) ever contains a specific value.
> Alternatively, how can I see all the values that the document ever had
> for the field. I don't expect this to actually be possible, but I ask
> if it is, i.e. by examining certain aspects of the Solr index with a
> text editor.
>
> 2) If those spurious results are appearing does that mean necessarily
> that those values for the multivalued field were in fact once in the
> multivalued field for documents matching the filter query? Thus, the
> answer to the previous question would be to simply run a query for the
> id of the document in question, and facet on the multivalued field
> with a large limit.
>
> 3) How to have Solr return only those faceting values for the field
> that in fact begin with 'dotan-', even if a document has other tags
> such as 'beatles'?
>
> 4) How to have Solr return only those faceting values which are larger
> than 0?
>
> Thank you!
>
> --
> Dotan Cohen
>
> http://gibberish.co.il
> http://what-is-what.com
>



-- 
Brendan Grainger
www.kuripai.com

Re: Receiving unexpected Faceting results.

Posted by Dotan Cohen <do...@gmail.com>.
On Wed, Jun 5, 2013 at 3:38 PM, Raymond Wiker <rw...@gmail.com> wrote:
> 3) Use the parameter facet.prefix, e.g, facet.prefix=dotan-. Note: this
> particular case will not work if the field you're facetting on is tokenised
> (with "-" being used as a taken separator).
>
> 4) Use the parameter facet.mincount - looks like you want to set it to 1,
> instead of the default which is 0.

Perfect, thank you Raymond!

--
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com

Re: Receiving unexpected Faceting results.

Posted by Raymond Wiker <rw...@gmail.com>.
3) Use the parameter facet.prefix, e.g, facet.prefix=dotan-. Note: this
particular case will not work if the field you're facetting on is tokenised
(with "-" being used as a taken separator).

4) Use the parameter facet.mincount - looks like you want to set it to 1,
instead of the default which is 0.