Query on facet field’s count

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Query on facet field’s count

Rajinimaski
Query on facet field results...


       When I run a facet query on some field say : facet=on &
facet.field=StudyID I get list of distinct StudyID list with the count that
tells that how many times did this study occur in the search query.  But I
also needed the count of these distinct StudyID list.. Any solr query to get
count of it..



Example:



   <lst name="*facet_fields*">

    <lst name=" StudyID ">

  <int name="*105*">135164</int>

  <int name="*179*">79820</int>

  <int name="*107*">70815</int>

  <int name="*120*">37076</int>

  <int name="*134*">35276</int>

  </lst>

</lst>



I wanted the count attribute that shall return the count of number of
different studyID occurred .. In above example  it could be  : Count = 5
(105,179,107,120,134)



<lst name="*facet_fields*">

 <lst name=" StudyID "  COUNT=5 >

  <int name="*105*">135164</int>

  <int name="*179*">79820</int>

  <int name="*107*">70815</int>

  <int name="*120*">37076</int>

  <int name="*134*">35276</int>

  </lst>

</lst>
Reply | Threaded
Open this post in threaded view
|

Re: Query on facet field’s count

Erick Erickson
There's nothing that I know of that gives you this, but it's
simple to count the members of the list yourself...

Best
Erick

On Fri, Mar 11, 2011 at 3:34 AM, rajini maski <[hidden email]> wrote:

> Query on facet field results...
>
>
>       When I run a facet query on some field say : facet=on &
> facet.field=StudyID I get list of distinct StudyID list with the count that
> tells that how many times did this study occur in the search query.  But I
> also needed the count of these distinct StudyID list.. Any solr query to get
> count of it..
>
>
>
> Example:
>
>
>
>   <lst name="*facet_fields*">
>
>    <lst name=" StudyID ">
>
>  <int name="*105*">135164</int>
>
>  <int name="*179*">79820</int>
>
>  <int name="*107*">70815</int>
>
>  <int name="*120*">37076</int>
>
>  <int name="*134*">35276</int>
>
>  </lst>
>
> </lst>
>
>
>
> I wanted the count attribute that shall return the count of number of
> different studyID occurred .. In above example  it could be  : Count = 5
> (105,179,107,120,134)
>
>
>
> <lst name="*facet_fields*">
>
>  <lst name=" StudyID "  COUNT=5 >
>
>  <int name="*105*">135164</int>
>
>  <int name="*179*">79820</int>
>
>  <int name="*107*">70815</int>
>
>  <int name="*120*">37076</int>
>
>  <int name="*134*">35276</int>
>
>  </lst>
>
> </lst>
>
Reply | Threaded
Open this post in threaded view
|

Re: Query on facet field’s count

Billnbell
In reply to this post by Rajinimaski
There is my patch to do that. SOLR-2242

Bill Bell
Sent from mobile


On Mar 11, 2011, at 1:34 AM, rajini maski <[hidden email]> wrote:

> Query on facet field results...
>
>
>       When I run a facet query on some field say : facet=on &
> facet.field=StudyID I get list of distinct StudyID list with the count that
> tells that how many times did this study occur in the search query.  But I
> also needed the count of these distinct StudyID list.. Any solr query to get
> count of it..
>
>
>
> Example:
>
>
>
>   <lst name="*facet_fields*">
>
>    <lst name=" StudyID ">
>
>  <int name="*105*">135164</int>
>
>  <int name="*179*">79820</int>
>
>  <int name="*107*">70815</int>
>
>  <int name="*120*">37076</int>
>
>  <int name="*134*">35276</int>
>
>  </lst>
>
> </lst>
>
>
>
> I wanted the count attribute that shall return the count of number of
> different studyID occurred .. In above example  it could be  : Count = 5
> (105,179,107,120,134)
>
>
>
> <lst name="*facet_fields*">
>
> <lst name=" StudyID "  COUNT=5 >
>
>  <int name="*105*">135164</int>
>
>  <int name="*179*">79820</int>
>
>  <int name="*107*">70815</int>
>
>  <int name="*120*">37076</int>
>
>  <int name="*134*">35276</int>
>
>  </lst>
>
> </lst>
Reply | Threaded
Open this post in threaded view
|

Re: Query on facet field¹s count

Billnbell
http://localhost:8983/solr/select?q=*:*&facet=true&facet.field=StudyID&face
t.mincount=1&facet.limit=-1&f.StudyID.facet.namedistinct=1

Would do what you want I believe...



On 3/11/11 8:51 AM, "Bill Bell" <[hidden email]> wrote:

>There is my patch to do that. SOLR-2242
>
>Bill Bell
>Sent from mobile
>
>
>On Mar 11, 2011, at 1:34 AM, rajini maski <[hidden email]> wrote:
>
>> Query on facet field results...
>>
>>
>>       When I run a facet query on some field say : facet=on &
>> facet.field=StudyID I get list of distinct StudyID list with the count
>>that
>> tells that how many times did this study occur in the search query.
>>But I
>> also needed the count of these distinct StudyID list.. Any solr query
>>to get
>> count of it..
>>
>>
>>
>> Example:
>>
>>
>>
>>   <lst name="*facet_fields*">
>>
>>    <lst name=" StudyID ">
>>
>>  <int name="*105*">135164</int>
>>
>>  <int name="*179*">79820</int>
>>
>>  <int name="*107*">70815</int>
>>
>>  <int name="*120*">37076</int>
>>
>>  <int name="*134*">35276</int>
>>
>>  </lst>
>>
>> </lst>
>>
>>
>>
>> I wanted the count attribute that shall return the count of number of
>> different studyID occurred .. In above example  it could be  : Count = 5
>> (105,179,107,120,134)
>>
>>
>>
>> <lst name="*facet_fields*">
>>
>> <lst name=" StudyID "  COUNT=5 >
>>
>>  <int name="*105*">135164</int>
>>
>>  <int name="*179*">79820</int>
>>
>>  <int name="*107*">70815</int>
>>
>>  <int name="*120*">37076</int>
>>
>>  <int name="*134*">35276</int>
>>
>>  </lst>
>>
>> </lst>


Reply | Threaded
Open this post in threaded view
|

Re: Query on facet field¹s count

Rajinimaski
Thanks Bill Bell . .This query works after applying the patch you refered
to, is it? Please can you let me know how do I need to update the current
war (apache solr 1.4.1 )file with this new patch? Thanks a lot.

Thanks,
Rajani

On Sat, Mar 12, 2011 at 8:56 AM, Bill Bell <[hidden email]> wrote:

> http://localhost:8983/solr/select?q=*:*&facet=true&facet.field=StudyID&face
> t.mincount=1&facet.limit=-1&f.StudyID.facet.namedistinct=1
>
> Would do what you want I believe...
>
>
>
> On 3/11/11 8:51 AM, "Bill Bell" <[hidden email]> wrote:
>
> >There is my patch to do that. SOLR-2242
> >
> >Bill Bell
> >Sent from mobile
> >
> >
> >On Mar 11, 2011, at 1:34 AM, rajini maski <[hidden email]> wrote:
> >
> >> Query on facet field results...
> >>
> >>
> >>       When I run a facet query on some field say : facet=on &
> >> facet.field=StudyID I get list of distinct StudyID list with the count
> >>that
> >> tells that how many times did this study occur in the search query.
> >>But I
> >> also needed the count of these distinct StudyID list.. Any solr query
> >>to get
> >> count of it..
> >>
> >>
> >>
> >> Example:
> >>
> >>
> >>
> >>   <lst name="*facet_fields*">
> >>
> >>    <lst name=" StudyID ">
> >>
> >>  <int name="*105*">135164</int>
> >>
> >>  <int name="*179*">79820</int>
> >>
> >>  <int name="*107*">70815</int>
> >>
> >>  <int name="*120*">37076</int>
> >>
> >>  <int name="*134*">35276</int>
> >>
> >>  </lst>
> >>
> >> </lst>
> >>
> >>
> >>
> >> I wanted the count attribute that shall return the count of number of
> >> different studyID occurred .. In above example  it could be  : Count = 5
> >> (105,179,107,120,134)
> >>
> >>
> >>
> >> <lst name="*facet_fields*">
> >>
> >> <lst name=" StudyID "  COUNT=5 >
> >>
> >>  <int name="*105*">135164</int>
> >>
> >>  <int name="*179*">79820</int>
> >>
> >>  <int name="*107*">70815</int>
> >>
> >>  <int name="*120*">37076</int>
> >>
> >>  <int name="*134*">35276</int>
> >>
> >>  </lst>
> >>
> >> </lst>
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Query on facet field’s count

Jonathan Rochkind
In reply to this post by Erick Erickson
It's not easy if you have lots of facet values (in my case, can even be
up to a million), but there is no way built-in to Solr to get this.  I
have been told that some of the faceting strategies (there are actually
several in use in Solr based on your parameters and the nature of your
data) return the page of facet values without actually counting all
possible facet values, which is what would make this difficult. But I
have not looked at the code myself.

Jonathan

On 3/11/2011 7:33 AM, Erick Erickson wrote:

> There's nothing that I know of that gives you this, but it's
> simple to count the members of the list yourself...
>
> Best
> Erick
>
> On Fri, Mar 11, 2011 at 3:34 AM, rajini maski<[hidden email]>  wrote:
>> Query on facet field results...
>>
>>
>>        When I run a facet query on some field say : facet=on&
>> facet.field=StudyID I get list of distinct StudyID list with the count that
>> tells that how many times did this study occur in the search query.  But I
>> also needed the count of these distinct StudyID list.. Any solr query to get
>> count of it..
>>
>>
>>
>> Example:
>>
>>
>>
>>    <lst name="*facet_fields*">
>>
>>     <lst name=" StudyID ">
>>
>>   <int name="*105*">135164</int>
>>
>>   <int name="*179*">79820</int>
>>
>>   <int name="*107*">70815</int>
>>
>>   <int name="*120*">37076</int>
>>
>>   <int name="*134*">35276</int>
>>
>>   </lst>
>>
>> </lst>
>>
>>
>>
>> I wanted the count attribute that shall return the count of number of
>> different studyID occurred .. In above example  it could be  : Count = 5
>> (105,179,107,120,134)
>>
>>
>>
>> <lst name="*facet_fields*">
>>
>>   <lst name=" StudyID "  COUNT=5>
>>
>>   <int name="*105*">135164</int>
>>
>>   <int name="*179*">79820</int>
>>
>>   <int name="*107*">70815</int>
>>
>>   <int name="*120*">37076</int>
>>
>>   <int name="*134*">35276</int>
>>
>>   </lst>
>>
>> </lst>
>>
Reply | Threaded
Open this post in threaded view
|

Re: Query on facet field¹s count

Billnbell
In reply to this post by Rajinimaski
My patch is for 4.0 trunk.

On Fri, Mar 11, 2011 at 10:05 PM, rajini maski <[hidden email]> wrote:

> Thanks Bill Bell . .This query works after applying the patch you refered
> to, is it? Please can you let me know how do I need to update the current
> war (apache solr 1.4.1 )file with this new patch? Thanks a lot.
>
> Thanks,
> Rajani
>
> On Sat, Mar 12, 2011 at 8:56 AM, Bill Bell <[hidden email]> wrote:
>
>> http://localhost:8983/solr/select?q=*:*&facet=true&facet.field=StudyID&face
>> t.mincount=1&facet.limit=-1&f.StudyID.facet.namedistinct=1
>>
>> Would do what you want I believe...
>>
>>
>>
>> On 3/11/11 8:51 AM, "Bill Bell" <[hidden email]> wrote:
>>
>> >There is my patch to do that. SOLR-2242
>> >
>> >Bill Bell
>> >Sent from mobile
>> >
>> >
>> >On Mar 11, 2011, at 1:34 AM, rajini maski <[hidden email]> wrote:
>> >
>> >> Query on facet field results...
>> >>
>> >>
>> >>       When I run a facet query on some field say : facet=on &
>> >> facet.field=StudyID I get list of distinct StudyID list with the count
>> >>that
>> >> tells that how many times did this study occur in the search query.
>> >>But I
>> >> also needed the count of these distinct StudyID list.. Any solr query
>> >>to get
>> >> count of it..
>> >>
>> >>
>> >>
>> >> Example:
>> >>
>> >>
>> >>
>> >>   <lst name="*facet_fields*">
>> >>
>> >>    <lst name=" StudyID ">
>> >>
>> >>  <int name="*105*">135164</int>
>> >>
>> >>  <int name="*179*">79820</int>
>> >>
>> >>  <int name="*107*">70815</int>
>> >>
>> >>  <int name="*120*">37076</int>
>> >>
>> >>  <int name="*134*">35276</int>
>> >>
>> >>  </lst>
>> >>
>> >> </lst>
>> >>
>> >>
>> >>
>> >> I wanted the count attribute that shall return the count of number of
>> >> different studyID occurred .. In above example  it could be  : Count = 5
>> >> (105,179,107,120,134)
>> >>
>> >>
>> >>
>> >> <lst name="*facet_fields*">
>> >>
>> >> <lst name=" StudyID "  COUNT=5 >
>> >>
>> >>  <int name="*105*">135164</int>
>> >>
>> >>  <int name="*179*">79820</int>
>> >>
>> >>  <int name="*107*">70815</int>
>> >>
>> >>  <int name="*120*">37076</int>
>> >>
>> >>  <int name="*134*">35276</int>
>> >>
>> >>  </lst>
>> >>
>> >> </lst>
>>
>>
>>
>
Reply | Threaded
Open this post in threaded view
|

SOLR-2242-distinctFacet.patch

Isha Garg
In reply to this post by Jonathan Rochkind
Hi,
       I  want to enquire the patch for
namedistinct(SOLR-2242-distinctFacet.patch) available with solr4.0 trunk

On Monday 14 March 2011 08:05 PM, Jonathan Rochkind wrote:

> It's not easy if you have lots of facet values (in my case, can even
> be up to a million), but there is no way built-in to Solr to get
> this.  I have been told that some of the faceting strategies (there
> are actually several in use in Solr based on your parameters and the
> nature of your data) return the page of facet values without actually
> counting all possible facet values, which is what would make this
> difficult. But I have not looked at the code myself.
>
> Jonathan
>
> On 3/11/2011 7:33 AM, Erick Erickson wrote:
>> There's nothing that I know of that gives you this, but it's
>> simple to count the members of the list yourself...
>>
>> Best
>> Erick
>>
>> On Fri, Mar 11, 2011 at 3:34 AM, rajini maski<[hidden email]>  
>> wrote:
>>> Query on facet field results...
>>>
>>>
>>>        When I run a facet query on some field say : facet=on&
>>> facet.field=StudyID I get list of distinct StudyID list with the
>>> count that
>>> tells that how many times did this study occur in the search query.  
>>> But I
>>> also needed the count of these distinct StudyID list.. Any solr
>>> query to get
>>> count of it..
>>>
>>>
>>>
>>> Example:
>>>
>>>
>>>
>>> <lst name="*facet_fields*">
>>>
>>> <lst name=" StudyID ">
>>>
>>> <int name="*105*">135164</int>
>>>
>>> <int name="*179*">79820</int>
>>>
>>> <int name="*107*">70815</int>
>>>
>>> <int name="*120*">37076</int>
>>>
>>> <int name="*134*">35276</int>
>>>
>>> </lst>
>>>
>>> </lst>
>>>
>>>
>>>
>>> I wanted the count attribute that shall return the count of number of
>>> different studyID occurred .. In above example  it could be  : Count
>>> = 5
>>> (105,179,107,120,134)
>>>
>>>
>>>
>>> <lst name="*facet_fields*">
>>>
>>> <lst name=" StudyID "  COUNT=5>
>>>
>>> <int name="*105*">135164</int>
>>>
>>> <int name="*179*">79820</int>
>>>
>>> <int name="*107*">70815</int>
>>>
>>> <int name="*120*">37076</int>
>>>
>>> <int name="*134*">35276</int>
>>>
>>> </lst>
>>>
>>> </lst>
>>>

Reply | Threaded
Open this post in threaded view
|

Re: Query on facet field¹s count

Rajinimaski
In reply to this post by Rajinimaski
Sorry for the late reply to this thread.

I implemented the same patch (solr 2242 )in Solr 1.4.1. Now I am able to
get distinct facet terms count across single index. But this does not work
for distributed process(sharding)..Is there a recent patch that has same
functionality for distributed process?


It works for the below query:
"
http://localhost:8983/solr/select?q=*:*&facet=true&facet.field=StudyID&facet.mincount=1&facet.limit=-1&f.StudyID.facet.namedistinct=1
"

It doesn't work for :
http://localhost:8983/solr/select?q=*:*&facet=true&facet.field=StudyID&facet.mincount=1&facet.limit=-1&f.StudyID.facet.namedistinct=1
&shards=localhost:8090/solr2

It gets matched result set from both the cores but facet results are only
from first core.

Rajani


On Sat, Mar 12, 2011 at 10:35 AM, rajini maski <[hidden email]>wrote:

> Thanks Bill Bell . .This query works after applying the patch you refered
> to, is it? Please can you let me know how do I need to update the current
> war (apache solr 1.4.1 )file with this new patch? Thanks a lot.
>
> Thanks,
> Rajani
>
> On Sat, Mar 12, 2011 at 8:56 AM, Bill Bell <[hidden email]> wrote:
>
>>
>> http://localhost:8983/solr/select?q=*:*&facet=true&facet.field=StudyID&face
>> t.mincount=1&facet.limit=-1&f.StudyID.facet.namedistinct=1<http://localhost:8983/solr/select?q=*:*&facet=true&facet.field=StudyID&facet.mincount=1&facet.limit=-1&f.StudyID.facet.namedistinct=1>
>>
>> Would do what you want I believe...
>>
>>
>>
>> On 3/11/11 8:51 AM, "Bill Bell" <[hidden email]> wrote:
>>
>> >There is my patch to do that. SOLR-2242
>> >
>> >Bill Bell
>> >Sent from mobile
>> >
>> >
>> >On Mar 11, 2011, at 1:34 AM, rajini maski <[hidden email]> wrote:
>> >
>> >> Query on facet field results...
>> >>
>> >>
>> >>       When I run a facet query on some field say : facet=on &
>> >> facet.field=StudyID I get list of distinct StudyID list with the count
>> >>that
>> >> tells that how many times did this study occur in the search query.
>> >>But I
>> >> also needed the count of these distinct StudyID list.. Any solr query
>> >>to get
>> >> count of it..
>> >>
>> >>
>> >>
>> >> Example:
>> >>
>> >>
>> >>
>> >>   <lst name="*facet_fields*">
>> >>
>> >>    <lst name=" StudyID ">
>> >>
>> >>  <int name="*105*">135164</int>
>> >>
>> >>  <int name="*179*">79820</int>
>> >>
>> >>  <int name="*107*">70815</int>
>> >>
>> >>  <int name="*120*">37076</int>
>> >>
>> >>  <int name="*134*">35276</int>
>> >>
>> >>  </lst>
>> >>
>> >> </lst>
>> >>
>> >>
>> >>
>> >> I wanted the count attribute that shall return the count of number of
>> >> different studyID occurred .. In above example  it could be  : Count =
>> 5
>> >> (105,179,107,120,134)
>> >>
>> >>
>> >>
>> >> <lst name="*facet_fields*">
>> >>
>> >> <lst name=" StudyID "  COUNT=5 >
>> >>
>> >>  <int name="*105*">135164</int>
>> >>
>> >>  <int name="*179*">79820</int>
>> >>
>> >>  <int name="*107*">70815</int>
>> >>
>> >>  <int name="*120*">37076</int>
>> >>
>> >>  <int name="*134*">35276</int>
>> >>
>> >>  </lst>
>> >>
>> >> </lst>
>>
>>
>>
>