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

Avoid retrieving duplicate documents by ID #134

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bkis
Copy link

@bkis bkis commented Feb 10, 2025

/dicts/foo/restful/ids?ids=bar&ids=bar&ids=bar&ids=bar returns the same document four times. I am aware this doesn't mean the end of the world, but maybe something close.

This just ensures the ids list that came from the controller and is passed to elasticsearch-dsl's doc.mget method contains only unique IDs by doing a quick list(set(ids)).

Technically, set(ids) would be enough, as elasticsearch-dsl just loops over the elements of any sequence, but the docs argument of mget is documented as a "list of ids of the documents to be retrieved or a list of document specifications" (although the type hint for docs is List[Dict[str, Any]], so I guess they're just being sloppy with their docs and/or type hints anyway).

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.

1 participant