On Mon, Mar 7, 2016 at 5:49 PM, Iana Bondarska <yana2...@gmail.com> wrote:
> Hi All,
> could you please tell me if escaping special characters in search keywords
> works in json api.
> e.g. I have document
>  {
> "string_s":"new value"
> }
> And I want to query "string_s" field with keyword "new value".
> In path params api I can escape spaces in keyword as well as other special
> characters with \ .
> following query finds document:
> http://localhsot:8983/solr/dynamic_fields_qa/select?q=string_s:new\
> value&wt=json&indent=true
> But if I try to run same search using json api, nothing is found:
>
> http://localhsot:8983/solr/dynamic_fields_qa/select?q=*:*&json=
> {"query":"string_s:new\ value"}

So the issue here is probably double-decoding... the JSON parser will
see the backslash-space and replace it with space only, and then the
lucene query parser will not see the backslash at all.

Either
1) use a double backslash
2) enclose the string in quotes (which will need to be backslash
escaped at the JSON level, or you can use the json single-quote
support.)

-Yonik

Reply via email to