7 ms·
Once again Xe nails it. > Go's type system is insufficiently typeful to handle the unrestrained madness that is ElasticSearch JSON. At first the article talks
by cratermoon 3y ago
Once again Xe nails it.
> Go's type system is insufficiently typeful to handle the unrestrained madness that is ElasticSearch JSON.
At first the article talks about feeding the API the raw JSON string, and I thought to myself, "wait! there's a typeful API, too". I'm impressed that the article doesn't ignore it, but zeroes straight to the main point of friction it has.
Maybe the API should be re-written to use generics now that they are available. That leaves the typing up to the programmer's specific domain and allows ES to to focus on the mechanism of the describing the search itself.
- xena 3y agoYou'd need Rust's type system to truly express the way that ElasticSearch uses JSON. I don't think it would be worth the effort. I'd probably use the json macro with serde.
- Andys 3y agoThere should be a middle ground. The Elasticsearch Go API is one of those auto-generated ones that only covers the bare basics, not helpful for constructing complex searches or parsing responses. A higher-level library + structures are needed.