I can't reproduce the problem you described -- using 7.2.1 and the 
techproducts example i can index a JSON string w/white space just fine...

$ bin/solr -e techproducts
$ curl 'http://localhost:8983/solr/techproducts/update/json/docs' -H 
'Content-type:application/json' -d '
{
  "id":"1",
  "name_s": "Joe Smith",
  "phone_s": 876876687}'
{
  "responseHeader":{
    "status":0,
    "QTime":5}}

Your specific curl command had some oddities in it (".\" before "curl";
"-H" on a new line w/o "\" escaping the newline) that may have just been
artifacts of copy/paste into email...

But even when trying to run the command as i think you intended it, i did 
not get a JSON parsing error regarding space -- just a nested doc error 
because your "split" param wasn't compatible with the configured default 
"srcField" option in the techproducts configset...

$ curl 
'http://localhost:8983/solr/techproducts/update/json/docs?srcField=&split=/|/orgs'
 -H 'Content-type:application/json' -d '
{
  "id":"1",
  "name_s": "Joe Smith",
  "phone_s": 876876687,
  "orgs": [
    {
      "name1_s" : "Microsoft",
      "city_s" : "Seattle",
      "zip_s" : 98052},
    {
      "name1_s" : "Apple",
      "city_s" : "Cupertino",
      "zip_s" : 95014}
  ]
}'
{
  "responseHeader":{
    "status":400,
    "QTime":2},
  "error":{
    "metadata":[
      "error-class","org.apache.solr.common.SolrException",
      "root-error-class","org.apache.solr.common.SolrException"],
    "msg":"Raw data can be stored only if split=/",
    "code":400}}




Are you *certain* it was a plain old space character, and that you didn't 
somehow get an EOF character or NUL byte in there some how?

Can you try running your curl command with the '--trace -' option and send 
us the full output?





: Date: Thu, 22 Mar 2018 23:48:21 +0800
: From: Zheng Lin Edwin Yeo <edwinye...@gmail.com>
: Reply-To: solr-user@lucene.apache.org
: To: solr-user@lucene.apache.org
: Subject: Error in indexing JSON with space in value
: 
: Hi,
: 
: I am trying to index the following JSON, in which there is a space in the
: name "Joe Smith".
: 
: .\curl 'http://localhost:8983/solr/collection/update/json/docs?split=/|/orgs
: '
:     -H 'Content-type:application/json' -d '
: {
:   "id":"1",
:   "name_s": "Joe Smith",
:   "phone_s": 876876687,
:   "orgs": [
:     {
:       "name1_s" : "Microsoft",
:       "city_s" : "Seattle",
:       "zip_s" : 98052},
:     {
:       "name1_s" : "Apple",
:       "city_s" : "Cupertino",
:       "zip_s" : 95014}
:   ]
: }'
: 
: However, I get the following error during the indexing.
: 
: {
:   "responseHeader":{
:     "status":400,
:     "QTime":1},
:   "error":{
:     "metadata":[
:       "error-class","org.apache.solr.common.SolrException",
:       "root-error-class","org.apache.solr.common.SolrException"],
:     "msg":"Cannot parse provided JSON: Expected ',' or '}':
: char=(EOF),position=24 AFTER=''",
:     "code":400}}
: curl: (3) [globbing] bad range specification in column 39
: 
: 
: If I remove the space in "Joe Smith" to make it "JoeSmith", then the
: indexing is successful. What can we do if we want to keep the space in the
: name? Do we need to include some escape characters or something?
: 
: I'm using Solr 7.2.1.
: 
: Regards,
: Edwin
: 

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

Reply via email to