Hi,
I'm new to Elasticsearch and building out mappings. I'm writing the JSON files before loading them into Elasticsearch.
If there was a JSON Schema defining the request body my IDE could provide Intellisense and validation which would be super helpful. Right now I have to try loading the mapping and then use the error message to see what is wrong.
I didn't see any schemas in the repo. If I write some is this something you would accept a PR for?
Have you considered looking at Console (in Kibana) for auto-completion while writing these mapping files? You might find that this already meets your needs.
As far as the specific proposal here, my take is that unless there is a very clear, large benefit from this we should be reluctant to add formal JSON schemas. The reason I think is because something like this comes with a high maintenance cost. To reduce this maintenance cost, we would want support in the build for it, either to fail the build if the schema is misaligned with the code, or to have the schemas automatically generated from the code. Yet that carries a large upfront infrastructure cost so I'm back to wondering whether there is a very clear, large benefit here.
We discussed this as part of FixItFriday. We have REST spec for urls and params, but we have no spec for request and response bodies. It would be nice to have a body spec not only for the mappings API, but for all of our API. That could help the knowledge base in Sense, and help high level clients generating requests and reading responses back. It could also be used as some sort of documentation.
We have discussed this quite a few times. We would like to have this, the .NET client team has made some effort in this direction. I think we tried json schema a while ago but it turned out to be not flexible enough for our needs. Swagger may have had similar problems if I remember correctly. From recent discussions it was clear that if we make this effort, those spec would be part of the elasticsearch repo together with the existing spec.
We may look at this again as part of the Java High Level client effort further down the road, yet it is a big project and I am not sure when we will get to it. I will close this issue for now, we will open a new one whenever we have a concrete plan on how to tackle this. I don't think we'll want to accept external contributions on this as we would have to make it work the way that our clients would use it , in a format that makes everybody happy etc. so it is probably easier if it comes from us.
Alrighty, Thanks for the quick response and all the info!
I needed this so I created a small script to generate JSON Schema from Elasticsearch mappings: elasticsearch2jsonschema
any updates on this @javanna ?
I would be very interested by this enhancement, notably to have auto-completion in IDE when defining an elasticsearch index template.
It is very useful, either in a Logstash project or a Filebeat project, or Custom app project.
My team would also be highly interested in such schema definitions. Is there another issue for tracking this request? Since this one is closed.
Most helpful comment
any updates on this @javanna ?