Parse json files

(deseint) #1

I would like to parse a JSON file with ElasticSearch.
In which directory must I put this file ?

Because when I execute this command:
POST /eurogiciel/test/ --data-binary @test.json
POST /eurogiciel/test/ -d @test.json

In my SENSE dashboard,I've got this error message :
{"error": "MapperParsingException[failed to parse]; nested:
ElasticsearchParseException[Failed to derive xcontent]; ",
"status": 400}

NB: my test.json file contains :
{"title": "billy","amount": 5.7}

Thanks a lot for your help.

(David Pilato) #2

Don't use SENSE in that case. Use CURL for example

(deseint) #3

Thank you for answer

But even else where, my curl command doesn't work as I described the error message.
So my question is : where am I supposed to put the files I want to import into ElasticSearch ?
Is the data directory (C:\Program Files (x86)\elasticsearch-1.7.2\data) expected to store this files ?

(David Pilato) #4

It's not a question related to elasticsearch here but to CURL.
Here CURL under windows.

I'd read the documentation about curl.
I can't answer myself as I don't use this under windows ( and I have a limited usage of curl).

BTW what do you want to achieve? Is it that you want to run that in production?

I mean that with curl you can directly send the json content without needing a file for this.

Answering to your question: you can store your file wherever you want.

(deseint) #5

Ok I would like to put my json files in this directory:
C:\Program Files (x86)\elasticsearch-1.7.2\data\*.json

This files are supposed to contain big data encoded in base64...(but for the moment I'm just making tests with a file.json very simple)

How ElasticSearch knows where are this files ? Because the curl command doesn't specify the path I mean...strange no ?

(Camilo Sierra) #6

when you use a curl function curl -XPOST 'http://jfblouvmlxecs01:9200/test/test/1' -d @lane.json > that means that jane.json is in the current file where you made your curl ! but how says @dadoonet this is not about ES but about how execute commands !

  1. go to C:\Program Files (x86)\elasticsearch-1.7.2\ (your json is hear, ex : test.json)
  2. stay in the same path, and execute your curl > curl -XPOST 'http://jfblouvmlxecs01:9200/test/test/1' -d @test.json

(David Pilato) #7

But please don't put any file in elasticsearch data dir.
Put your files in whatever dir you want but not there.

(deseint) #8

Ok I understand.
I executed my command curl via windows console like this :
C:\Program Files (x86)\elasticsearch-1.7.2\data>curl -XPOST 'http://localhost:9200/eurogiciel/cv/1' -d @test.json
but this message error appears:
'curl' is not a command...

So I've download curl.exe with GOW (version Gow-0.7.0.exe)
And my command curl did work !!
Thank you very much :smile:

(system) #9