elasticsearch-py icon indicating copy to clipboard operation
elasticsearch-py copied to clipboard

Generate typed JSON object structures and enums from the Elasticsearch Specification

Open sethmlarson opened this issue 4 years ago • 0 comments

Generate these structures using https://github.com/elastic/elasticsearch-specification and make them available through elasticsearch.types.* modules. This will allow having type-hints for APIs, especially useful for complex structures like query DSL:

from elasticsearch import Elasticsearch
from elasticsearch.types import ExpandWildcards, MatchQuery

client = Elasticsearch()
client.search(
    index="index",
    expand_wildcards=[ExpandWildcards.OPEN, ExpandWildcards.CLOSED],
    query={
        "match": {
            "field": MatchQuery(query="text")
        }
    }
)

All of these structures would be serialized to the proper JSON/HTTP structures before being handed to the transport layer.

sethmlarson avatar Aug 25 '21 12:08 sethmlarson