joshi123 joshi123 - 9 months ago 46
JSON Question

elasticsearch mapping no JSON object error

I'm trying to load data to elasticsearch 5 using the python script csv2es.

argument passed to csv2es references a json file with the elasticsearch mappings. when loading the mappings file below:

"dynamic": "true",
"properties": {
"username": {"type": “text”},
"date": {"type": "date", "format" : "yyyy-MM-dd HH:mm"},
"retweets": {"type": “integer”},
"favourites": {"type": “integer”},
"text": {"type": “text”},
"geo": {"type": “keyword”},
"mentions": {"type": “text”},
"hashtags": {"type": “text”},
"id": {"type": “keyword”},
"permalink": {"type": “keyword”}

this throws the following error:

Applying mapping from: csv2es_mappings.json
Traceback (most recent call last):
File "/usr/local/bin/csv2es", line 11, in <module>
File "/usr/local/lib/python2.7/site-packages/click/", line 664, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/click/", line 644, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python2.7/site-packages/click/", line 837, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python2.7/site-packages/click/", line 464, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/", line 206, in cli
mapping = json.loads(
File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/", line 339, in loads
return _default_decoder.decode(s)
File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/", line 364, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/", line 382, in raw_decode
raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

However when I load the following file the data load runs. I'm using
instead of
as per the guidance for ES5 mappings- when using
the fields are not picked up and indexed properly.

"dynamic": "true",
"properties": {
"username": {"type": "string"},
"date": {"type": "date", "format" : "yyyy-MM-dd HH:mm"},
"retweets": {"type": "string"},
"favourites": {"type": "string"},
"text": {"type": "string"},
"geo": {"type": "string"},
"mentions": {"type": "string"},
"hashtags": {"type": "string"},
"id": {"type": "string"},
"permalink": {"type": "string"}

Answer Source

afaik, that error means your json data is invalid. In “text”, thats surrounded by left double quotation mark instead " quotation mark.

Upgrade your python, so you can see readable error while decode json string or use simplejson library.

See this: Displaying better error message than "No JSON object could be decoded"