Open oeed opened 3 years ago
Hi @oeed, I think #126 is going in the direction that you're after. Ideally, you'd be able to do
let response = client
.search("my_index")
.q("title:Elasticsearch")
.send()
.await?;
In its current form this isn't yet possible, the nearest being
let response = client
.search(&["my_index"][..])
.q("title:Elasticsearch")
.send()
.await?;
It'd be good to revisit, to see how we might go about this. I think the parts enums will likely end up owning their inputs for this to work.
Is your feature request related to a problem? Please describe. 95% of my queries are only ever on a single index and I've found it a bit difficult/unergonomic to try and search for these when they're not
'static
. BecauseSearchParts::Index
takes&[&str]
you have to wrap the single string like&[my_str]
, which doesn't work in situation where you return the SearchParts by value, not reference, like this (it's a bit of a contrived example, but I've run in to it in various situations):You get a
cannot return value referencing temporary value, returns a value referencing data owned by the current function
error. My index names are dynamic and so can't be static, this becomes an issue because the variant requires a reference to an array of references, which I simply can't figure out how to do within a single struct.I'm still a bit new to Rust though, so if there's actually a good solution to this I'd love to know, I haven't been able to find one though.
Describe the solution you'd like I'm far from a Rust expert as I've said, so there may be better ways; but the idea that comes to mind is to simply providing additional variants.
i.e.
The implementation of
SearchParts
looks fairly straight forward so I'd be happy to provide a PR if open to the idea.Describe alternatives you've considered With a few layers of indirection and nested structs this is possible, but it's rather messy and unergonomic.