pksprojects / ElasticSwift

Elasticsearch client in swift
MIT License
46 stars 18 forks source link

GetIndexRequest - API result is not parsed properly #9

Closed lubbo closed 5 years ago

lubbo commented 5 years ago

In the GetIndexRequest method func responseHandler(_ response: ESResponse) -> Void deserializing the response in let decoded: GetIndexResponse? = try Serializers.decode(data: response.data!) always throw an keyNotFound exception.

This because it expect to find a GetIndexResponse object in the JSON result with following attributes:

instead ElasticSearch JSON wraps this object inside an attribute with the name of the index retrieved.

Expected JSON: {"aliases":{},"mappings":{},"settings":{"index":{"creation_date":"1559206573432","number_of_shards":"1","number_of_replicas":"1","uuid":"I6Ep6P6FQI2wplQCckfr6Q","version":{"created":"7000199"},"provided_name":"test"}}}

Actual JSON: {"test": {"aliases":{},"mappings":{},"settings":{"index":{"creation_date":"1559206573432","number_of_shards":"1","number_of_replicas":"1","uuid":"I6Ep6P6FQI2wplQCckfr6Q","version":{"created":"7000199"},"provided_name":"test"}}} }

prafsoni commented 5 years ago

@lubbo Please include ElasticSwift and Elasticsearch versions you are using. The current version of ElasticSwift is tested against es-6.2.x

lubbo commented 5 years ago

I’m using 7.0, 6.8 still have this format as per official docs: https://www.elastic.co/guide/en/elasticsearch/reference/6.8/indices-get-index.html

Maybe that is changed in 6.8

prafsoni commented 5 years ago

19