: I am finding that if any fields in a document returned by a Solr query
: (*wt=json* to get a JSON response) contain backslash *'\'* characters, they
: are not being escaped (to make then valid JSON).

you're going to have to give us more concrete specifics on how you are 
indexing your data, and how you are looking at the response, because i 
can't reproduce anything close to what you are describing (see below)

https://wiki.apache.org/solr/UsingMailingLists




hossman@frisbee:~$ cat tmp/tmp.xml 
<add>
  <doc>
    <field name="id">HOSS</field>
    <field name="name">quote: (") backslash: (\) backslash-quote: (\") 
newline: (
) backslash-n: (\n)</field>
  </doc>
</add>


hossman@frisbee:~$ curl 
'http://localhost:8983/solr/collection1/update?commit=true' --data-binary 
@tmp/tmp.xml -H 'Content-Type: application/xml'
<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader"><int name="status">0</int><int 
name="QTime">678</int></lst>
</response>



hossman@frisbee:~$ curl 
'http://localhost:8983/solr/collection1/select?q=id:HOSS&indent=true&omitHeader=true&wt=xml'
<?xml version="1.0" encoding="UTF-8"?>
<response>

<result name="response" numFound="1" start="0">
  <doc>
    <str name="id">HOSS</str>
    <str name="name">quote: (") backslash: (\) backslash-quote: (\") 
newline: (
) backslash-n: (\n)</str>
    <long name="_version_">1458038035233898496</long></doc>
</result>
</response>


hossman@frisbee:~$ curl 
'http://localhost:8983/solr/collection1/select?q=id:HOSS&indent=true&omitHeader=true&wt=json'
{
  "response":{"numFound":1,"start":0,"docs":[
      {
        "id":"HOSS",
        "name":"quote: (\") backslash: (\\) backslash-quote: (\\\") 
newline: (\n) backslash-n: (\\n)",
        "_version_":1458038035233898496}]
  }}


hossman@frisbee:~$ cat tmp/tmp.json
[
 {"id" : "HOSS", 
  "name" : "quote: (\") backslash: (\\) backslash-quote: (\\\") newline: 
(\n) backslash-n: (\\n)"}
]


hossman@frisbee:~$ curl 
'http://localhost:8983/solr/collection1/update?commit=true' --data-binary 
@tmp/tmp.json -H 'Content-Type: application/json'
{"responseHeader":{"status":0,"QTime":605}}


hossman@frisbee:~$ curl 
'http://localhost:8983/solr/collection1/select?q=id:HOSS&indent=true&omitHeader=true&wt=xml'
<?xml version="1.0" encoding="UTF-8"?>
<response>

<result name="response" numFound="1" start="0">
  <doc>
    <str name="id">HOSS</str>
    <str name="name">quote: (") backslash: (\) backslash-quote: (\") 
newline: (
) backslash-n: (\n)</str>
    <long name="_version_">1458038130437259264</long></doc>
</result>
</response>


hossman@frisbee:~$ curl 
'http://localhost:8983/solr/collection1/select?q=id:HOSS&indent=true&omitHeader=true&wt=json'
{
  "response":{"numFound":1,"start":0,"docs":[
      {
        "id":"HOSS",
        "name":"quote: (\") backslash: (\\) backslash-quote: (\\\") 
newline: (\n) backslash-n: (\\n)",
        "_version_":1458038130437259264}]
  }}




-Hoss
http://www.lucidworks.com/

Reply via email to