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

helpers.scan doesn't work #11

Open
tdhopper opened this issue May 9, 2018 · 4 comments
Open

helpers.scan doesn't work #11

tdhopper opened this issue May 9, 2018 · 4 comments

Comments

@tdhopper
Copy link

tdhopper commented May 9, 2018

I'm trying to use elasticsearch.helpers.scan with the mocked ES. It apparently doesn't work because the results don't include a _scroll_id: https://github.com/elastic/elasticsearch-py/blob/9fe0763670633848b521ff9df6350bc811f4f110/elasticsearch/helpers/__init__.py#L367. Is it insane to think about adding this functionality, or does that get way complicated?

@anneschuth
Copy link

Same here and I come to the same conclusion. Would you consider a PR in this direction?

@vrcmarcos
Copy link
Owner

Sorry guys, but I do not have too much time to maintain this library. But you can always send a PR with this improvement :)

@mohantyashish109
Copy link
Contributor

You can mock the elastic search scan something like the below code

from elasticsearch_dsl import AttrDict
def mock_elasticsearch_scan():
    class Search:
        """Dummy Search class

        """

        def __init__(self):
            pass

        def scan(self):
            yield AttrDict({
                'x': 1,
                'y': 1,
                })

    return Search()

@limjcst
Copy link

limjcst commented Oct 21, 2021

_scroll_id has been introduced in #17 . However, helpers.scan is still broken.
The following trick seems to work

from elasticmock.fake_elasticsearch import FakeElasticsearch


def _mock_clear_scroll(client: FakeElasticsearch, *args, **kwargs):
    # pylint: disable=unused-argument
    pass


FakeElasticsearch.clear_scroll = _mock_clear_scroll

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

No branches or pull requests

5 participants