Skip to content

Are rollup searches supported? #1637

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

Open
mathijsfr opened this issue Dec 20, 2022 · 1 comment
Open

Are rollup searches supported? #1637

mathijsfr opened this issue Dec 20, 2022 · 1 comment

Comments

@mathijsfr
Copy link

How do I search rollups? The documentation doesn't show anything on rollup searches.

@alick97
Copy link

alick97 commented Jan 31, 2023

How do I search rollups? The documentation doesn't show anything on rollup searches.

not found in official, but this hook may run with unknow bug

from elasticsearch_dsl import Search
from elasticsearch_dsl.connections import get_connection
from elasticsearch.client.utils import GLOBAL_PARAMS

class RollupSearch(Search)
    _ALLOW_ROLLUP_SEARCH_PARAM = set(["rest_total_hits_as_int", "typed_keys", *GLOBAL_PARAMS])
    
    def execute(self, ignore_cache=False):
        """
        Execute the search and return an instance of ``Response`` wrapping all
        the data.

        :arg ignore_cache: if set to ``True``, consecutive calls will hit
            ES, while cached result will be ignored. Defaults to `False`
        """
        if ignore_cache or not hasattr(self, "_response"):
            es = get_connection(self._using)
            es.search()
            self._response = self._response_class(
                self, es.rollup.rollup_search(index=self._index, body=self.to_dict(), **{k:v for k,v in self._params.items() if  k in self._ALLOW_ROLLUP_SEARCH_PARAM})
            )
        return self._response

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

No branches or pull requests

3 participants