Jan Høydahl created SOLR-18482:
----------------------------------

             Summary: JSON range facet silently ignores `limit`, `offset`, 
`sort` and the refine parameters
                 Key: SOLR-18482
                 URL: https://issues.apache.org/jira/browse/SOLR-18482
             Project: Solr
          Issue Type: Bug
            Reporter: Jan Høydahl
            Assignee: Jan Høydahl


Found by Claude Code

A {{type: range}} facet in the JSON Facet API accepts {{limit}}, {{offset}}, 
{{sort}}, {{prelim_sort}}, {{overrequest}}, {{overrefine}} and {{refine}} and 
ignores them without any error or warning.

{code:title=POST /solr/techproducts/query}
{"query":"*:*","limit":0,"facet":{"p":{"type":"range","field":"price",
  "start":0,"end":1000,"gap":250,"limit":1,"offset":1,"sort":"count desc"}}}
{code}

returns every bucket in ascending range order — {{limit}}, {{offset}} and 
{{sort}} have no effect. The same request against a {{type: terms}} facet 
honours all three, and the ref guide's examples make the two facet types look 
interchangeable, so users copy these keys across and get a plausible-looking 
wrong answer.

h3. Cause

{{FacetRange extends FacetRequestSorted}}, so the request object carries the 
fields, but {{FacetParser.FacetRangeParser.parse}} never reads them from the 
JSON (compare {{FacetFieldParser.parse}}, which does). The map helpers do not 
reject unknown keys, so the values are dropped silently. 
{{FacetRangeProcessor}} never consults them.

h3. Proposal

At minimum, reject these keys on a range facet with a 400 naming the key 
({{sort is not supported on range facets}}), and state in the _Range Facet_ 
section of the JSON Facet API page which of the common facet parameters do not 
apply. Implementing sort/paging over range buckets is a possible follow-up, but 
the silent ignore is the bug.

Found while deriving a JSON Schema of the request DSL from source; the schema 
deliberately omits these keys from range facets so an editor can flag them.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to