How to push json into elasticsearch

I want to push the following Json data using Python in elasticsearch, I used the following code but there is no data in the index.
json data :
[
"break",
false,
-1314177328.9280925,
[
-107585784.0005331,
1173232087.3724098,
[
true,
-1841424252.6783514,
true,
"typical",
true,
false
],
false,
1593426885.6051607,
true
],
"parent",
false
]

If the json is malformed elastic will reject the document, try to use logstash http input plugin with stdout rubydbg to see what you are really sending. check if the json is well structured with an online json checker

1 Like

There are restrictions in what JSON you can index into Elasticsearch, and what you have posted is not valid in Elasticsearch. The root bust be a well formed JSON object and can not be an array. Elasticsearch is also not schemaless, so once a field has been mapped it can not accept values that are not aligned to this mapping.

1 Like

hi @A_Mightiev, Jason data is valid, I checked

It is valid JSON, but not in a form Elasticsearch will accept.

1 Like

Can you help me @Christian_Dahlqvist ? I am a beginner and the result of this task is very important to me:(

Have you looked at the Elasticsearch getting started guide and the examples available there?

1 Like

no i didn't

Then please do so. You will need to learn about how Elasticsearch works if you are going to use it. The section on mapping describes how document structure and mapping works, and should explain why your document will not work in Elasticsearch.

1 Like

I can't find a document that explains what Jsons are accepted by Elasticsearch... I would be grateful if you could send me a link or a document that can help me and improve my situation.

I added a link to the documentation on mapping to my earlier response. A document must be an object with at least one field, e.g. {"field:"value"}. An array at the highest level is not acceptable.

Furthermore each field must have a single mapping. Although a field can contain an array, all values within the array must be of the same type, so you can e.g. not mix strings, numbers and objects in an array.

This blog post may also be useful, although it is quite old and quite a few things have changed since.

1 Like

Thank you very much, you helped me a lot. I will definitely read the points you said

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.