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 deniz <de...@gmail.com> on 2017/02/07 08:54:33 UTC

Interval Facets with JSON

Hello,

I am trying to run JSON facets with on interval query as follows:

  
"json.facet":{"height_facet":{"interval":{"field":"height","set":["[160,180]","[180,190]"]}}}

And related field is <field name="height" type="tint" indexed="true"
stored="true" />

But I keep seeing errors like:

    o.a.s.h.RequestHandlerBase org.apache.solr.common.SolrException: Unknown
facet or stat. key=height_facet type=interval args={field=height,
set=[[160,180], [180,190]]} , path=/facet


I have tried to find example for the json facets with intervals but couldnt
find anything... almost everywhere having examples for range queries rather
than interval...

the thing i am trying to achive is the same/similar response with:

   
/select?facet=on&indent=on&q=*:*&wt=json&facet.interval=height&f.height.facet.interval.set=[0,155]&f.height.facet.interval.set=(155,165] 

in case i directly query solr with the above query, i am able to see the
facets. 

solr version i use is 6.1.0

is it something missing or incorrect in the syntax that i use for json
facets? anyone had similar issues with interval facets with json?






-----
Zeki ama calismiyor... Calissa yapar...
--
View this message in context: http://lucene.472066.n3.nabble.com/Interval-Facets-with-JSON-tp4319111.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Interval Facets with JSON

Posted by Tomás Fernández Löbbe <to...@gmail.com>.
Hi Deniz,
Interval Facets is currently not supported with JSON Facets as Tom said.
Could you create a Jira issue?

On Fri, Feb 10, 2017 at 6:16 AM, Tom Evans <te...@googlemail.com> wrote:

> On Wed, Feb 8, 2017 at 11:26 PM, deniz <de...@gmail.com> wrote:
> > Tom Evans-2 wrote
> >> I don't think there is such a thing as an interval JSON facet.
> >> Whereabouts in the documentation are you seeing an "interval" as JSON
> >> facet type?
> >>
> >>
> >> You want a range facet surely?
> >>
> >> One thing with range facets is that the gap is fixed size. You can
> >> actually do your example however:
> >>
> >> json.facet={hieght_facet:{type:range, gap:20, start:160, end:190,
> >> hardend:True, field:height}}
> >>
> >> If you do require arbitrary bucket sizes, you will need to do it by
> >> specifying query facets instead, I believe.
> >>
> >> Cheers
> >>
> >> Tom
> >
> >
> > nothing other than
> > https://cwiki.apache.org/confluence/display/solr/Faceting#Faceting-
> IntervalFaceting
> > for documentation on intervals...  i am ok with range queries as well but
> > intervals would fit better because of different sizes...
>
> That documentation is not for JSON facets though. You can't pick and
> choose features from the old facet system and use them in JSON facets
> unless they are mentioned in the JSON facet documentation:
>
> https://cwiki.apache.org/confluence/display/solr/JSON+Request+API
>
> and (not official documentation)
>
> http://yonik.com/json-facet-api/
>
> Cheers
>
> Tom
>

Re: Interval Facets with JSON

Posted by Tom Evans <te...@googlemail.com>.
On Wed, Feb 8, 2017 at 11:26 PM, deniz <de...@gmail.com> wrote:
> Tom Evans-2 wrote
>> I don't think there is such a thing as an interval JSON facet.
>> Whereabouts in the documentation are you seeing an "interval" as JSON
>> facet type?
>>
>>
>> You want a range facet surely?
>>
>> One thing with range facets is that the gap is fixed size. You can
>> actually do your example however:
>>
>> json.facet={hieght_facet:{type:range, gap:20, start:160, end:190,
>> hardend:True, field:height}}
>>
>> If you do require arbitrary bucket sizes, you will need to do it by
>> specifying query facets instead, I believe.
>>
>> Cheers
>>
>> Tom
>
>
> nothing other than
> https://cwiki.apache.org/confluence/display/solr/Faceting#Faceting-IntervalFaceting
> for documentation on intervals...  i am ok with range queries as well but
> intervals would fit better because of different sizes...

That documentation is not for JSON facets though. You can't pick and
choose features from the old facet system and use them in JSON facets
unless they are mentioned in the JSON facet documentation:

https://cwiki.apache.org/confluence/display/solr/JSON+Request+API

and (not official documentation)

http://yonik.com/json-facet-api/

Cheers

Tom

Re: Interval Facets with JSON

Posted by deniz <de...@gmail.com>.
Tom Evans-2 wrote
> I don't think there is such a thing as an interval JSON facet.
> Whereabouts in the documentation are you seeing an "interval" as JSON
> facet type?
> 
> 
> You want a range facet surely?
> 
> One thing with range facets is that the gap is fixed size. You can
> actually do your example however:
> 
> json.facet={hieght_facet:{type:range, gap:20, start:160, end:190,
> hardend:True, field:height}}
> 
> If you do require arbitrary bucket sizes, you will need to do it by
> specifying query facets instead, I believe.
> 
> Cheers
> 
> Tom


nothing other than
https://cwiki.apache.org/confluence/display/solr/Faceting#Faceting-IntervalFaceting
for documentation on intervals...  i am ok with range queries as well but
intervals would fit better because of different sizes...

i have also checked the class FacetRequest after digging through the error
stack and found the lines below:

public Object parseFacetOrStat(String key, String type, Object args) throws
SyntaxError {
    // TODO: a place to register all these facet types?

    if ("field".equals(type) || "terms".equals(type)) {
      return parseFieldFacet(key, args);
    } else if ("query".equals(type)) {
      return parseQueryFacet(key, args);
    } else if ("range".equals(type)) {
      return parseRangeFacet(key, args);
    }

    AggValueSource stat = parseStat(key, type, args);
    if (stat == null) {
      throw err("Unknown facet or stat. key=" + key + " type=" + type + "
args=" + args);
    }

couldnt find any other class which is extending this method either... so
simply i will switch to ranges for now...

thanks a lot for your suggestions





-----
Zeki ama calismiyor... Calissa yapar...
--
View this message in context: http://lucene.472066.n3.nabble.com/Interval-Facets-with-JSON-tp4319111p4319402.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Interval Facets with JSON

Posted by Tom Evans <te...@googlemail.com.INVALID>.
On Tue, Feb 7, 2017 at 8:54 AM, deniz <de...@gmail.com> wrote:
> Hello,
>
> I am trying to run JSON facets with on interval query as follows:
>
>
> "json.facet":{"height_facet":{"interval":{"field":"height","set":["[160,180]","[180,190]"]}}}
>
> And related field is <field name="height" type="tint" indexed="true"
> stored="true" />
>
> But I keep seeing errors like:
>
>     o.a.s.h.RequestHandlerBase org.apache.solr.common.SolrException: Unknown
> facet or stat. key=height_facet type=interval args={field=height,
> set=[[160,180], [180,190]]} , path=/facet
>

I don't think there is such a thing as an interval JSON facet.
Whereabouts in the documentation are you seeing an "interval" as JSON
facet type?


You want a range facet surely?

One thing with range facets is that the gap is fixed size. You can
actually do your example however:

json.facet={hieght_facet:{type:range, gap:20, start:160, end:190,
hardend:True, field:height}}

If you do require arbitrary bucket sizes, you will need to do it by
specifying query facets instead, I believe.

Cheers

Tom

Re: Interval Facets with JSON

Posted by deniz <de...@gmail.com>.
I have taken a look at the class
solr/core/src/test/org/apache/solr/search/facet/TestJsonFacets.java but it
seems like there are no tests for interval facets on json...






-----
Zeki ama calismiyor... Calissa yapar...
--
View this message in context: http://lucene.472066.n3.nabble.com/Interval-Facets-with-JSON-tp4319111p4319254.html
Sent from the Solr - User mailing list archive at Nabble.com.