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 preetesh dubey <du...@gmail.com> on 2012/06/08 18:22:27 UTC

terms count in multivalues field

Is it possible to get number of entries present in a multivalued field by
solr query. Lets say I want to query to solr to get all documents having *
count* of some multivalued field >1. Is it possible in solr ?

-- 
Thanks & Regards
Preetesh Dubey

Re: terms count in multivalues field

Posted by preetesh dubey <du...@gmail.com>.
Thanks Jack!
Creating another field to store the count is one option. I just wanted to
know if this was possible without adding new field to schema. And I got the
answer, it's not possible atleast in solr 3.x versions.
Thanks once again for your reply and infromation about " Toolkit of
UpdateProcessors " in 4.x version.

On Sun, Jun 10, 2012 at 12:55 AM, Jack Krupansky <ja...@basetechnology.com>wrote:

> I am not aware of any function query to get the value count for a
> multivalued field.
>
> You could write a custom update processor which counted the values and
> then stored the count in another field. Then you could do a numeric range
> query on that other field. Or maybe even store a boolean in another field
> to indicate whether the field had a single value or more than a threshold
> count of values, or whatever custom calculation you wanted.
>
> Of course, you could also count the values yourself and setting a separate
> count field before submitting the document to Solr.
>
> See SOLR-2802 - "Toolkit of UpdateProcessors for modifying document
> values" for some possible base classes for such an update processor. This
> is for 4.x, not 3.6. For older releases, you will have to do it all
> yourself.
> https://issues.apache.org/**jira/browse/SOLR-2802<https://issues.apache.org/jira/browse/SOLR-2802>
>
> -- Jack Krupansky
>
> -----Original Message----- From: preetesh dubey
> Sent: Friday, June 08, 2012 12:22 PM
> To: solr-user@lucene.apache.org
> Subject: terms count in multivalues field
>
>
> Is it possible to get number of entries present in a multivalued field by
> solr query. Lets say I want to query to solr to get all documents having *
> count* of some multivalued field >1. Is it possible in solr ?
>
>
> --
> Thanks & Regards
> Preetesh Dubey
>



-- 
Thanks & Regards
Preetesh Dubey

Re: terms count in multivalues field

Posted by Jack Krupansky <ja...@basetechnology.com>.
I am not aware of any function query to get the value count for a 
multivalued field.

You could write a custom update processor which counted the values and then 
stored the count in another field. Then you could do a numeric range query 
on that other field. Or maybe even store a boolean in another field to 
indicate whether the field had a single value or more than a threshold count 
of values, or whatever custom calculation you wanted.

Of course, you could also count the values yourself and setting a separate 
count field before submitting the document to Solr.

See SOLR-2802 - "Toolkit of UpdateProcessors for modifying document values" 
for some possible base classes for such an update processor. This is for 
4.x, not 3.6. For older releases, you will have to do it all yourself.
https://issues.apache.org/jira/browse/SOLR-2802

-- Jack Krupansky

-----Original Message----- 
From: preetesh dubey
Sent: Friday, June 08, 2012 12:22 PM
To: solr-user@lucene.apache.org
Subject: terms count in multivalues field

Is it possible to get number of entries present in a multivalued field by
solr query. Lets say I want to query to solr to get all documents having *
count* of some multivalued field >1. Is it possible in solr ?

-- 
Thanks & Regards
Preetesh Dubey