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 Moazzam Khan <mo...@gmail.com> on 2010/08/10 20:31:24 UTC
Need help with facets
Hi guys,
I have a solr index whose documents have the following fields:
FirstName
LastName
RecruitedDate
I update the index when any of the three fields change for that specific person.
I need to get facets based on when someone was recruited. The facets are :
Recruited within 1 month
Recruited within 3 months
...
So if 10 people were recruited within the past month then the count
for r"Recruited within 1 month" will be 10.
Is there a way to calculate the facets from RecruitedDate? Or, will I
have to create another field (let's say) RecruitedDateFacet and store
the text in there?
My problem is that if I use a separate field for faceting and store a
string in it then if that person's information wasn't updated for a
month he would still fall in that category (since no delta query was
run)
Please advise on what is the best way to accomplish this.
Thanks in advance,
Moazzam
Re: Need help with facets
Posted by Moazzam Khan <mo...@gmail.com>.
That's awesome.
Thanks Ahmet!
On Wed, Aug 11, 2010 at 1:50 AM, Ahmet Arslan <io...@yahoo.com> wrote:
>
>
> --- On Wed, 8/11/10, Moazzam Khan <mo...@gmail.com> wrote:
>
>> From: Moazzam Khan <mo...@gmail.com>
>> Subject: Re: Need help with facets
>> To: solr-user@lucene.apache.org
>> Date: Wednesday, August 11, 2010, 1:32 AM
>> Thanks Ahmet that worked!
>>
>> Here's another issues I have :
>>
>> Like I said before, I have these fields in Solr documents
>>
>> FirstName
>> LastName
>> RecruitedDate
>> VolumeDate (just added this in this email)
>> VolumeDone (just added this in this email)
>>
>>
>> Now I have to get sum of all VolumeDone (integer field) for
>> this month
>> by everyone, then take 25% of that number and get all
>> people whose
>> volume was more than that. Is there a way to do this? :D
>
> You need to execute two queries for that. Stats Component can give you sum. q=VolumeDate:[NOW-1MONTH TO NOW]&stats=true&stats.field=VolumeDone
>
> http://wiki.apache.org/solr/StatsComponent
>
> Then second query
> q=VolumeDate:[NOW-1MONTH TO NOW]&fq=VolumeDone:[sumComesAbove TO *]
>
> But you need to use tint type instead of int for VolumeDone, to range queries work correctly.
>
>
>
>
Re: Need help with facets
Posted by Ahmet Arslan <io...@yahoo.com>.
--- On Wed, 8/11/10, Moazzam Khan <mo...@gmail.com> wrote:
> From: Moazzam Khan <mo...@gmail.com>
> Subject: Re: Need help with facets
> To: solr-user@lucene.apache.org
> Date: Wednesday, August 11, 2010, 1:32 AM
> Thanks Ahmet that worked!
>
> Here's another issues I have :
>
> Like I said before, I have these fields in Solr documents
>
> FirstName
> LastName
> RecruitedDate
> VolumeDate (just added this in this email)
> VolumeDone (just added this in this email)
>
>
> Now I have to get sum of all VolumeDone (integer field) for
> this month
> by everyone, then take 25% of that number and get all
> people whose
> volume was more than that. Is there a way to do this? :D
You need to execute two queries for that. Stats Component can give you sum. q=VolumeDate:[NOW-1MONTH TO NOW]&stats=true&stats.field=VolumeDone
http://wiki.apache.org/solr/StatsComponent
Then second query
q=VolumeDate:[NOW-1MONTH TO NOW]&fq=VolumeDone:[sumComesAbove TO *]
But you need to use tint type instead of int for VolumeDone, to range queries work correctly.
Re: Need help with facets
Posted by Moazzam Khan <mo...@gmail.com>.
Thanks Ahmet that worked!
Here's another issues I have :
Like I said before, I have these fields in Solr documents
FirstName
LastName
RecruitedDate
VolumeDate (just added this in this email)
VolumeDone (just added this in this email)
Now I have to get sum of all VolumeDone (integer field) for this month
by everyone, then take 25% of that number and get all people whose
volume was more than that. Is there a way to do this? :D
I did some research but I wasn't able to come up with an answer.
Thanks,
Moazzam
On Tue, Aug 10, 2010 at 1:42 PM, Ahmet Arslan <io...@yahoo.com> wrote:
>> I have a solr index whose documents have the following
>> fields:
>>
>> FirstName
>> LastName
>> RecruitedDate
>>
>> I update the index when any of the three fields change for
>> that specific person.
>>
>> I need to get facets based on when someone was recruited.
>> The facets are :
>>
>> Recruited within 1 month
>> Recruited within 3 months
>> ...
>>
>> So if 10 people were recruited within the past month then
>> the count
>> for r"Recruited within 1 month" will be 10.
>>
>> Is there a way to calculate the facets from RecruitedDate?
>
> It is possible with facet.query; something like:
>
> q=*:*&facet=on&facet.query=RecruitedDate:[NOW-1MONTH TO NOW]&facet.query=RecruitedDate:[NOW-3MONTHS TO NOW]
>
>
>
>
Re: Need help with facets
Posted by Ahmet Arslan <io...@yahoo.com>.
> I have a solr index whose documents have the following
> fields:
>
> FirstName
> LastName
> RecruitedDate
>
> I update the index when any of the three fields change for
> that specific person.
>
> I need to get facets based on when someone was recruited.
> The facets are :
>
> Recruited within 1 month
> Recruited within 3 months
> ...
>
> So if 10 people were recruited within the past month then
> the count
> for r"Recruited within 1 month" will be 10.
>
> Is there a way to calculate the facets from RecruitedDate?
It is possible with facet.query; something like:
q=*:*&facet=on&facet.query=RecruitedDate:[NOW-1MONTH TO NOW]&facet.query=RecruitedDate:[NOW-3MONTHS TO NOW]