Esempio n. 1
0
 def execute(self):
     """
     Execute the multi search request and return a list of search results.
     """
     es = get_connection(self._using)
     return es.msearch(index=self._index,
                       body=self.to_dict(),
                       **self._params)
Esempio n. 2
0
    def delete(self):
        """
        delete() executes the query by delegating to delete_by_query()
        """

        es = get_connection(self._using)

        return es.delete_by_query(index=self._index, body=self.to_dict())
Esempio n. 3
0
 def execute(self):
     """
     Execute the search and return an instance of ``Response`` wrapping all
     the data.
     """
     es = get_connection(self._using)
     return Response(es.search(index=self._index, body=self.to_dict()),
                     search=self)
Esempio n. 4
0
    def count(self):
        """
        Return the number of hits matching the query and filters. Note that
        only the actual number is returned.
        """
        es = get_connection(self._using)

        d = self.to_dict(count=True)
        return es.count(index=self._index, body=d)["count"]
Esempio n. 5
0
    def scan(self):
        """
        Turn the search into a scan search and return a generator that will
        iterate over all the documents matching the query.

        Use ``params`` method to specify any additional arguments you with to
        pass to the underlying ``scan`` helper from ``elasticsearch-py`` -
        https://elasticsearch-py.readthedocs.io/en/master/helpers.html#elasticsearch.helpers.scan

        """
        es = get_connection(self._using)

        for hit in scan(es, query=self.to_dict(), index=self._index):
            yield hit