All works fine, the document is updated and Kibana understand changes.
Although, I'm not Ok with static body of the query. There's necessity to update it according to some previous script manipulations. As a result the syntax looks somehow like this:
b = 'exaclty the same valid query' es.update(index='.kibana', doc_type='search', id='2f015f70-1ec1-11e7-88fa-XXXXXX', body={ b })
Even with the same syntax the update operation fails with:
elasticsearch.exceptions.SerializationError.
TypeError('Unable to serialize set(' HERE THE VALUE OF b VAR '))
As I understand, then Serialization is process of data format transformation, in this case string to JSON..?
So I've tried to manipulate with b variable using json module, with no success. The same exception appears after the variable was led through json.dumps(b) and json.loads(json.dumps(b)) operations.
Do you have any ideas, how to overcome this behavior?
Thanks!
As there's no answer from community, assume that workaround I used in this case may be useful for someone else in the future.
Unfortunately, I still don't know how to mitigate this ES behavior using Python Elastic module.
Next, what I've tried to do, is to use native ES Update API through HTTP using built in Python libraries like urllib* and requests.
I've tried both following requests examples:
requests.post('http://localhost:9200/.kibana/search/2f015f70-1ec1-11e7-88fa-XXXX/_update',data='some valid POST body')
and requests.post('http://localhost:9200/.kibana/search/2f015f70-1ec1-11e7-88fa-XXXX/_update',json='some valid POST body')
Although request was created with completely valid syntax (it worked within Dev Tools Console),
ES returned another type of exception:
(..)"type":"parse_exception","reason":"Failed to derive xcontent"(..)
So in the end I was forced to make call to OS shell, execute curl -XPOST <url> -d@<filename> flag.
Withing that file is placed that valid POST body, that in this case is sent to ES without any problems.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.