elastic / elasticsearch-rs

Official Elasticsearch Rust Client
https://www.elastic.co/guide/en/elasticsearch/client/rust-api/current/index.html
Apache License 2.0
695 stars 70 forks source link

[ENHANCEMENT] strong typed Response. #140

Closed GopherJ closed 3 years ago

GopherJ commented 3 years ago

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when there elasticsearch-rs is not strongly typed, I cannot deserialize my response to some kind of type.

elastic-rs has elastic-types if I rememembered correctly, cannot we port them here? Not strongly typed makes elasticsearch-rs not too many advantages over reqwest. It becomes only a wrapper of reqwest.....

Describe the solution you'd like A clear and concise description of what you want to happen.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.

GopherJ commented 3 years ago

https://docs.rs/elastic_types/0.21.0-pre.4/elastic_types/ this is less urgent

GopherJ commented 3 years ago

https://github.com/elastic-rs/elastic/blob/312eeb22b6ad60072a80680fbec27f466cdcb9b3/src/elastic/src/client/responses/search.rs#L78-L91

is more urgent I think, can we have it in elasticsearch-rs?

I need basically https://github.com/elastic-rs/elastic/blob/312eeb22b6ad60072a80680fbec27f466cdcb9b3/src/elastic/src/client/responses/bulk.rs#L149-L158, now I'll copy elastic-rs's code, but can we have them recently? Because I'll have other softwares to develop using elasticsearch-rs.

It's pretty important to have strongly typed response

GopherJ commented 3 years ago

A thing like https://docs.rs/elasticsearch/7.9.0-alpha.1/elasticsearch/http/response/struct.Response.html isn't really useful, we don't have other info except top-level error code, if it's bulk request the error code isn't that useful.

Somehow users will then need to define their own types, which decreases elasticsearch-rs's advantags over a pure reqwest.

I'm wondering if this means I should combine elasticsearch-rs and elastic-rs's types together?

GopherJ commented 3 years ago

@russcam Any idea on this?

russcam commented 3 years ago

@GopherJ there is already an issue open to discuss request and response types: #75. Please have a read of the other issue and discuss there. Thanks!.