Search code examples
javasolrfacetsolrjfaceted-search

Accessing Solr facet_ranges via Solrj


Maybe it is already to late, but I am struggling around with Solr's Facet Ranges. I can execute the query via Solrj, but I do not understand how to retrieve the results via Solrj. The QueryResponse object doesn't not give me the getter-methods for the ranges, does it?

E.g. the resulting XML looks like this:

<lst name="facet_counts">
<lst name="facet_queries"/>
<lst name="facet_fields"/>
<lst name="facet_dates"/>
<lst name="facet_ranges">
<lst name="my_field">
<lst name="counts">
<int name="2010-06-01T00:00:00Z">0</int>
<int name="2010-06-02T00:00:00Z">0</int>
<int name="2010-06-03T00:00:00Z">0</int>
...

and i want to get the data in counts.


Solution

  • I think the QueryResponse.getFacetRanges() method is what you want, but this is only available in very recent versions of SolrJ I think; 3.4.0 has it, but some earlier versions did not.