benashford / rs-es

A Rust client for the ElasticSearch REST API
Apache License 2.0
217 stars 44 forks source link

Indexing fails in ES 6.0+ #117

Open jmatraszek opened 5 years ago

jmatraszek commented 5 years ago

I know this is a part of #115, but indexing something using ES 6.0+ is improperly marked as an error by rs-es. The document is added to the index in ES, but due to lack of created attribute in the response from ES rs-es interprets this as an error and returns Err. You can see the docs here: https://www.elastic.co/guide/en/elasticsearch/reference/5.6/docs-index_.html https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-index_.html

I worked around this issue by changing created to be Option<bool> — this would support both ES version, but it also changes rs-es public API. You can check my change here: https://github.com/jmatraszek/rs-es/commit/60654614f043e53d5b047133edf66f1620f6b839

If think that such a small, gradual change towards supporting ES 6.0+ makes sense, I'd be happy to create a pull request. I'd also understand if you do not wish to merge that as it breaks rs-es public API without fixing the whole issue. :)

benashford commented 5 years ago

Thanks for raising this. Given that the baseline of the library is still targeted against ElasticSearch 2.0, I'm wary of it becoming potentially confusing by half-supporting higher versions (e.g. not also supporting all the query types).

But, changes like the one you suggest do sound sensible. It would allow the library to target a wider-range of ElasticSearch versions while still being consistent about the version supported.

Let me have a think. Perhaps the way forward is to use feature flags to unlock higher versions of ElasticSearch. That way we can gradually upgrade the library without having to have all the pieces in place.

2phost commented 5 years ago

I would like to know if there are some progress in this issue. Just because it is hard to know if there was some error or not in the newer Elasticsearch versions. I suggest something like a flag to specify the Elasticsearch version or check the version when creating the client with a simple call like this one: curl -XGET http://127.0.0.1:9200/