Sunday, April 1, 2018

FW: Error in indexing JSON with space in value

-----Original Message-----
From: Zheng Lin Edwin Yeo [mailto:edwinyeozl@gmail.com]
Sent: 22 March 2018 21:18
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

No comments:

Post a Comment