ElasticSearch - Julia

Viewed 113

I am trying to use elasticsearch with Julia ,when I try to connect to my index in Kibana I get this error :

PyError ($(Expr(:escape, :(ccall(#= /home/J1028071/.julia/packages/PyCall/zqDXB/src/pyfncall.jl:43 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) <class 'elasticsearch.exceptions.SerializationError'> SerializationError('Unknown mimetype, unable to deserialize: text/html')

Here is my code :

using PyCall
es = pyimport(“elasticsearch”)
js = pyimport(“json”)
client = es.Elasticsearch(“http://kibana-cig:5601”)
elastic_info = es.Elasticsearch.info(client)

If anyone has ever had this error or knows how to fix it…

Thank you for your help !

1 Answers

The problem in your code could be about passing the client object back from Julia to Python.

BTW you do not need Python's JSON. PyCall will translate Python dictionaries to Julia's Dicts.

This used to work for me

using PyCall
es= pyimport("elasticsearch")
client = es.Elasticsearch() #provide con info if needed

And now I just call methods of the client object rather than passing it around:

client.info()  

dat = Dict("col1"=>"some text", "col2"=>"more text")
res = client.index(index="data", doc_type="data", id="1", body=dat)

q = Dict("query"=>Dict("match"=>Dict("col1"=>Dict("query"=>"some text"))))

client.search("data",body=q)["hits"]["hits"]

Another thing. Most likely you are connecting to Kibana GUI rather than Elasticsearch API. Instead try using:

client = es.Elasticsearch("http://yourelastichostname:5601")

Let me know if it helped.

Related