[ 
https://issues.apache.org/jira/browse/SOLR-18482?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18122090#comment-18122090
 ] 

Nick Shanin commented on SOLR-18482:
------------------------------------

🤖 AI text below 🤖 (posted on behalf of Nick Shanin)

I opened a PR implementing the 400 proposal: 
https://github.com/apache/solr/pull/5009

FacetRangeParser rejects limit, offset, sort, prelim_sort, overrequest, 
overrefine and refine on range facets with a 400 naming the parameter, with 
tests and a ref guide note in the Range Facet section. One intentional behavior 
change: requests that carried these parameters and had them silently ignored 
before now fail with a 400.

> 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
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> 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