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 Mikhail Ibraheem <ar...@yahoo.com.INVALID> on 2017/06/04 10:57:32 UTC
Function queries with Json facet
Hi,I have a date field date_of_birth and have double field grade. I can easily get the sum of grades per date_of_birth value using:{ date_of_birth:{ type:terms, field:"date_of_birth", facet: { "metric":"sum(grade)" } }}
But what if I want to group only part of the date_of_birth? for example I want to get the sum of grade per year 2000?
This doesn't work:{ date_of_birth:{ type:terms, field:date_of_birth/YEAR, facet: { "metric":"sum(grade)" } }}
Please advise.
Thanks
Re: Function queries with Json facet
Posted by Susheel Kumar <su...@gmail.com>.
Also change manufacturedate_dt to dob field and price to grade...
On Mon, Jun 5, 2017 at 10:33 AM, Susheel Kumar <su...@gmail.com>
wrote:
> You are looking for something like below. Please adjust the start and
> end. You can also give a fixed date instead of NOW etc..
>
> curl http://localhost:8983/solr/techproducts/query -d 'q=*:*&
>
> json.facet={
>
> byyeaar:{
>
> type:range,
>
> field:"manufacturedate_dt",
>
> start : NOW-15YEAR/YEAR,
>
> end : NOW/YEAR,
>
> gap : "%2B1YEAR",
>
> other : "before",
>
> facet:{
>
> "metrics" : "sum(price)"
> }
> }
> }'
>
> On Sun, Jun 4, 2017 at 6:57 AM, Mikhail Ibraheem <
> arsenal2025@yahoo.com.invalid> wrote:
>
>> Hi,I have a date field date_of_birth and have double field grade. I can
>> easily get the sum of grades per date_of_birth value
>> using:{ date_of_birth:{ type:terms,
>> field:"date_of_birth", facet: { "metric":"sum(grade)" } }}
>> But what if I want to group only part of the date_of_birth? for example I
>> want to get the sum of grade per year 2000?
>> This doesn't work:{ date_of_birth:{ type:terms,
>> field:date_of_birth/YEAR, facet: { "metric":"sum(grade)" } }}
>> Please advise.
>> Thanks
>
>
>
Re: Function queries with Json facet
Posted by Susheel Kumar <su...@gmail.com>.
You are looking for something like below. Please adjust the start and
end. You can also give a fixed date instead of NOW etc..
curl http://localhost:8983/solr/techproducts/query -d 'q=*:*&
json.facet={
byyeaar:{
type:range,
field:"manufacturedate_dt",
start : NOW-15YEAR/YEAR,
end
: NOW/YEAR,
gap
: "%2B1YEAR",
other : "before",
facet:{
"metrics" : "sum(price)"
}
}
}'
On Sun, Jun 4, 2017 at 6:57 AM, Mikhail Ibraheem <
arsenal2025@yahoo.com.invalid> wrote:
> Hi,I have a date field date_of_birth and have double field grade. I can
> easily get the sum of grades per date_of_birth value
> using:{ date_of_birth:{ type:terms,
> field:"date_of_birth", facet: { "metric":"sum(grade)" } }}
> But what if I want to group only part of the date_of_birth? for example I
> want to get the sum of grade per year 2000?
> This doesn't work:{ date_of_birth:{ type:terms,
> field:date_of_birth/YEAR, facet: { "metric":"sum(grade)" } }}
> Please advise.
> Thanks