[
https://issues.apache.org/jira/browse/SOLR-17836?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18013119#comment-18013119
]
Chris M. Hostetter commented on SOLR-17836:
-------------------------------------------
{quote}
Running the following query via a request give the following error:
{quote}
You don't define what you mean by "via a request" but let's assume you mean
something like what i've got below -- where i use curl (maybe you use some
other library) passing in a URL where I have already include all of the request
params...
{noformat}
curl -sS --globoff
'http://localhost:8983/solr/techproducts/select?q=*:*&rows=0&json.facet={x:{type:range,field:y_dt,start:"NOW-10DAY/DAY",end:"NOW/DAY",gap:"+1DAY"}}'
{noformat}
Let's look very carefully at the entire response of my example -- paying
attention not only to the text of the error message, but also the *WHITESPACE*
in the error message, and the "params" echoed back to us in the
"responseHeader" ...
{noformat}
{
"responseHeader":{
"zkConnected":true,
"status":400,
"QTime":2,
"params":{
"q":"*:*",
"json.facet":"{x:{type:range,field:y_dt,start:\"NOW-10DAY/DAY\",end:\"NOW/DAY\",gap:\"
1DAY\"}}",
"rows":"0"
}
},
"response":{
"numFound":31,
"start":0,
"numFoundExact":true,
"docs":[ ]
},
"error":{
"metadata":["error-class","org.apache.solr.common.SolrException","root-error-class","java.text.ParseException"],
"msg":"Can't add gap 1DAY to value Thu Jul 31 00:00:00 UTC 2025 for field:
y_dt",
"code":400
}
}
{noformat}
When you give curl (or other libraries like it) a URL that already includes
request params, you are responsible for URL encoding any characters in that
URL. Solr is very forgiving, and doesn't _require_ that the entire URL be
properly url encoded -- ut it does respect any characters that are encoded.
{{"+"}} is the URL encoded form of a single space character (ie: {{" "}}) so
when you use a "raw" plus sign in your URL, solr's request parsing interprets
it as a single space character. You can see this in the params exchoed back,
as well as the "double space" in the error message...
{noformat}
"json.facet":"{x:{type:range,field:y_dt,start:\"NOW-10DAY/DAY\",end:\"NOW/DAY\",gap:\"
1DAY\"}}",
...
"msg":"Can't add gap 1DAY to value Thu Jul 31 00:00:00 UTC 2025 for field:
y_dt",
{noformat}
> JSON FACET API Error: cant add gap to value for field
> ------------------------------------------------------
>
> Key: SOLR-17836
> URL: https://issues.apache.org/jira/browse/SOLR-17836
> Project: Solr
> Issue Type: Bug
> Affects Versions: 9.8.1
> Reporter: Arsal Jalib
> Priority: Minor
>
> Running the following query via a request give the following error:
> [/solr/mindex|http://172.189.48.140/solr/m]/select?json.facet={
> last14Days:
> { type:range, field:ReleaseDate_PT1, start:"NOW-2MONTH/DAY",
> end:"NOW/DAY", gap:"+1DAY" }
> }
> lst name="error">
> <lst name="metadata">
> <str name="error-class">org.apache.solr.common.SolrException</str>
> <str name="root-error-class">java.text.ParseException</str>
> </lst>
> <str name="msg">Can't add gap 1DAY to value Thu Jun 05 00:00:00 UTC 2025 for
> field: ReleaseDate_PT1</str>
> <int name="code">400</int>
> </lst>
> </response>
> However the same JSON when entered using the json.facet text box in the Admin
> UI, it returns results fine.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]