Hello Thomas.
I think extensive use of local parameters references is easy than fighting
with escaping
q=inStock:true AND {!boost b=manufacturedate_dt v=$nameq}&nameq={!field
f=name}the (concept).xml
or even ...{!field f=name v=$nameval}&nameval=the (concept).xml
also depending on the field type you'd better use {!term}.
To continue post debugQuery=true output, when your query is parsed but
misbehave.

On Sat, Sep 14, 2024 at 11:57 AM Thomas Åkesson <thomas.akes...@fastmail.se>
wrote:

> Hi,
> We have come across a potentially incorrect lexical error with the
> following combination in the query:
>  - Parentheses in the search term (tried both escaping and quoting)
>  - Query parser within {}. Actual use-case is using !graph but clearer
> reproduction with something simple like !boost.
>  - Using AND before the {!something ...} query.
>
> This query fails:
> curl '
> http://localhost:8983/solr/demo/select?q=inStock:true+AND+%7B%21boost+b%3Dmanufacturedate_dt%7Dname%3Athe%2520%5C%28concept%5C%29.xml
> '
> {
>   "responseHeader":{
>     "status":400,
>     "QTime":1,
>     "params":{
>       "q":"inStock:true AND {!boost
> b=manufacturedate_dt}name:the%20\\(concept\\).xml"
>     }
>   },
>   "error":{
>
> "metadata":["error-class","org.apache.solr.common.SolrException","root-error-class","org.apache.solr.parser.TokenMgrError"],
>     "msg":"org.apache.solr.search.SyntaxError: Cannot parse
> 'name:the%20\\(concept\\': Lexical error at line 1, column 22.
> Encountered: <EOF> (in lexical state 3)",
>     "code":400
>   }
>
>
> Fails when quoted (no escaping needed?):
> curl '
> http://localhost:8983/solr/demo/select?q=inStock:true+AND+%7B%21boost+b%3Dmanufacturedate_dt%7Dname%3A%22the%2520%28concept%29.xml%22
> '
> {
>   "responseHeader":{
>     "status":400,
>     "QTime":1,
>     "params":{
>       "q":"inStock:true AND {!boost
> b=manufacturedate_dt}name:\"the%20(concept).xml\""
>     }
>   },
>   "error":{
>
> "metadata":["error-class","org.apache.solr.common.SolrException","root-error-class","org.apache.solr.parser.TokenMgrError"],
>     "msg":"org.apache.solr.search.SyntaxError: Cannot parse
> 'name:\"the%20(concept': Lexical error at line 1, column 21.  Encountered:
> <EOF> after prefix \"\\\"the%20(concept\" (in lexical state 3)",
>     "code":400
>   }
>
> Removing the closing parenthesis works:
> curl '
> http://localhost:8983/solr/demo/select?q=inStock:true+AND+%7B%21boost+b%3Dmanufacturedate_dt%7Dname%3Athe%2520%5C%28concept.xml
> '
>
> Removing the statement before works:
> curl '
> http://localhost:8983/solr/demo/select?q=%7B%21boost+b%3Dmanufacturedate_dt%7Dname%3Athe%2520%5C%28concept%5C%29.xml
> '
>
>
> Has anyone seen this issue before? Tested with 8.3 and 9.6.1.
>
> Thanks in advance,
> Thomas Å.
>
>
>
>
>
>
>
>
>

-- 
Sincerely yours
Mikhail Khludnev

Reply via email to