: I see no way to change the sort order to index (I want the output in 
: date order), I get results sorted on the count. I have tried adding the 
: sort field like so:

This ... doesn't make sense.  

AFAIK "index" order (or more specifically: The "natural order" of the 
bucket values) is the only possible sorting returned by JSON Range Facet 

ie: what you are asking for should be what you are getting, what you say 
you are getting shouldn't be possible.
(see examples below)


What does your solrj code that consumes the QueryResponse look like?


$ curl 'http://localhost:8983/solr/techproducts/query?rows=0&omitHeader=true' 
-d '
{
  "query": "*:*",
  "facet": {
    "prices": {
      "type": "range",
      "field": "price",
      "start": 0,
      "end": 100,
      "gap": 20
    }
  }
}'
{
  "response":{"numFound":32,"start":0,"numFoundExact":true,"docs":[]
  },
  "facets":{
    "count":32,
    "prices":{
      "buckets":[{
          "val":0.0,
          "count":5},
        {
          "val":20.0,
          "count":0},
        {
          "val":40.0,
          "count":0},
        {
          "val":60.0,
          "count":1},
        {
          "val":80.0,
          "count":1}]}}}


$ curl 
'http://localhost:8983/solr/techproducts/query?rows=0&omitHeader=true' -d'
{
  "query": "*:*",
  "facet": {
    "prices": {
      "type": "range",
      "field": "manufacturedate_dt",
      "start": "1900-01-01T00:00:00Z",
      "end": "2200-01-01T00:00:00Z",
      "gap": "+100YEARS"
    }
  }
}'
{
  "response":{"numFound":32,"start":0,"numFoundExact":true,"docs":[]
  },
  "facets":{
    "count":32,
    "prices":{
      "buckets":[{
          "val":"1900-01-01T00:00:00Z",
          "count":0},
        {
          "val":"2000-01-01T00:00:00Z",
          "count":11},
        {
          "val":"2100-01-01T00:00:00Z",
          "count":0}]}}}

Here's a test that uses SollrJ to assert that the execpted buckets come 
back in the expected order (by bucket value, not by bucket count) ...

https://github.com/apache/solr/blob/releases/solr/9.0.0/solr/solrj/src/test/org/apache/solr/client/ref_guide_examples/JsonRequestApiTest.java#L573-L596






-Hoss
http://www.lucidworks.com/

Reply via email to