Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type annotation of source parameter. #2347

Closed
wants to merge 2 commits into from

Conversation

JannKleen
Copy link

@JannKleen JannKleen commented Oct 20, 2023

This might be completely wrong, but I think the type hinting of the source parameter for Elasticsearch().search() should be Sequence[str] and not Mapping[str, Any] (s. https://www.elastic.co/guide/en/elasticsearch/reference/current/search-fields.html#source-filtering)
Also fields should be accepting str as well as Mapping[str, Any]

@pquentin
Copy link
Member

pquentin commented Oct 21, 2023

Hello, and thank you! However this code is generated from https://github.com/elastic/elasticsearch-specification/blob/main/specification/_global/search/SearchRequest.ts which is the place to fix if the type hint is wrong.

More specifically, https://github.com/elastic/elasticsearch-specification/blob/main/specification/_types/query_dsl/abstractions.ts is the definition of one field, which explains why it's a mapping. (The Python client only has types for the first level of objects.)

You are right that Elasticsearch accepts single strings too (https://www.elastic.co/guide/en/elasticsearch/reference/current/search-fields.html#search-fields-request shows it clearly) which suggests the specification repo could be fixed.

If you are unable to open an issue or pull request in that repository, I can look at this in more detail at the end of next week.

@pquentin
Copy link
Member

Closing in favor of elastic/elasticsearch-specification#2317. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants