JSON Facet API usage

162 views
Skip to first unread message

crawdaddy

unread,
Feb 4, 2015, 3:38:43 PM2/4/15
to helio...@googlegroups.com
Hi folks,

I must be missing something simple here, but I'm having trouble getting the JSON Facet API to work at all.  Today, I took a Solr 4.10.2 installation and swapped it out for HS 0.09.  Everything works at first blush - searching, my custom URPs and search components, etc.  However, I'm stuck moving from the Solr facet approach to the JSON approach.

For example, a standard Solr facet on field "language" can be returned using:

curl http://localhost:8983/solr/RTISearch/select -d 'rows=0&q=*:*&facet=true&facet.field=language'

The response contains the facets I expect:
{
  "responseHeader":{
    "status":0,
    "QTime":17,
    "params":{
      "facet":"true",
      "q":"*:*",
      "facet.field":"language",
      "rows":"0"}},
  "response":{"numFound":727709,"start":0,"maxScore":1.0,"docs":[]
  },
  "facet_counts":{
    "facet_queries":{},
    "facet_fields":{
      "language":[
        "en",727514,
        [... abbreviated ]
    "facet_dates":{},
    "facet_ranges":{},
    "facet_intervals":{}}}

-------------------------

Now I try the JSON API in the simple Terms Facet format, according to the guide:

json.facet={
  lang : { terms : language }
}
'

For this or several other variations, the response contains no facets:
{
  "responseHeader":{
    "status":0,
    "QTime":13,
    "params":{
      "q":"*:*",
      "json.facet":"{\nlanguage : { terms : { field : language } }\n}\n",
      "rows":"0"}},
  "response":{"numFound":727709,"start":0,"maxScore":1.0,"docs":[]
  }}

-------------------------

No errors in the logs.  Tried issuing these requests via BASH scripts and other ways - no dice.  If I purposely malform the JSON, I get a Noggit JSON error so I know it's parsing it.  If I add "facet=true" to the request, I get an empty "facet_counts" block.

Any help would be appreciated!



Yonik Seeley

unread,
Feb 5, 2015, 1:31:19 PM2/5/15
to helio...@googlegroups.com
What type of field is "language"? multi-valued? indexed? docvalues?
The new faceting stuff doesn't have full docvalues support yet.
-Yonik
> --
> You received this message because you are subscribed to the Google Groups
> "heliosearch" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to heliosearch...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

crawdaddy

unread,
Feb 5, 2015, 3:14:21 PM2/5/15
to helio...@googlegroups.com, yo...@heliosearch.com
Hi Yonik,

Just a simple string:
<field name="language" type="string" indexed="true" stored="true"/>

crawdaddy

unread,
Feb 10, 2015, 4:39:30 PM2/10/15
to helio...@googlegroups.com, yo...@heliosearch.com
The issue was around the use of a custom component list in my search handler.  The "hs_facet" component is included in the default list, but the defaults aren't used if you specify a custom component list.  Adding "hs_facet" into my list makes it work.

Yonik Seeley

unread,
Feb 11, 2015, 2:57:15 PM2/11/15
to helio...@googlegroups.com
Ah, of course! I had missed that there wasn't even a top level
"facets" in your response. Glad you tracked it down!

-Yonik
Reply all
Reply to author
Forward
0 new messages