JSON Schema for Query

I am looking for a JSON Schema that describes the Elastic Query syntax so I can use to validate queries in JSON form.

Is there something available?

Hi @JLarue, Welcome to the community. Have you had a look at the GET API for getting the mapping of your index. i.e. GET index_name/_mapping. Documentation is here
The response of this will fetch you the schema(also called as mapping in elasticsearch) for your index. This would be your default mappings which gets assigned when you index your data. You could also change that.
Hope that helps.

Hi and thank you for your reply. I have been invoking API for many months now, I am able to do that without issue, and can understand it through the reading of the documentation.

I have created a DSL Modeling tool which code generates microservices. These microservices follow the CQRS pattern. The write model flows data through Event Sourcing while projections subscribe to this data and persist into a read model based upon Elastic Search.

Within the DSL Modeling tool there lies an ability to define Query Commands on each domain service. Since these commands are the Q in CQRS, they will read and return data from the read model, which in this example is Elastic Search.

There is a JSON editor within the tool which provides an ability to extend the model's meta data through instances of JSON Schema.

In this scenario I am looking to define the Query DSL as a JSON Schema such that a Business Architect can define the Query Syntax that will be injected into the code by the code generator.

This is why I am looking for a relatively good JSON Schema that describes the Query DSL such that when selected, the Business Architect can simply fill in the query, mapping the domain command parameters to the the query that is code generated into the microservice.

So my question is as follows, is there a JSON Schema that describes the rules for Query DSL?

As far as I know there is no schema available, and this post is still valid.

1 Like

Thanks Christian... however I am puzzled by the following comment in the post cited in your link back.

We don't currently have an syntactical grammar / schema for the request bodies at the moment. Different APIs have different schemas, depending on the function of that schema. I'm afraid you'll just have to read the docs for the particular endpoints you are interested in to learn the schema, sorry.

There has to be somewhere within that validates each inbound query thus there has to be a set of rules that describe what is a valid request vs. not?

I would like someone to explain what is meant by

different APIs have different schemas

such that Query does not have a schema, or a set of rules that dictate it's usage outside of documentation.