def search_model_by_query(self, query=None, index=None): """ Search an index and a model using the Elasticsearch query DSL based on the contents of the given query. :param query: The BaseElasticsearchQuery object to query off of. :return: The result of elasticsearch.search. """ ValidationHelper.validate_es_query_type(query) return self.search_index( index=index, doc_type=query.doc_type, body=query.to_query_dict(), )
def update_model_by_query(self, query=None, index=None): """ Perform an update_by_query action on the Elasticsearch backend to update the model referenced inside of query by its contents. :param query: The query to use for the update. :param index: The index to perform the update on. :return: The Elasticsearch response. """ ValidationHelper.validate_es_query_type(query) return self.connection.update_by_query( index=index, doc_type=query.doc_type, body=query.to_query_dict(), )
def delete_model_by_query(self, query=None, index=None): """ Perform a delete_by_query query against the Elasticsearch backend that deletes all documents matching the query in query found within the given index. :param query: An Elasticsearch query instance. :param index: The index to perform the delete upon. :return: The Elasticsearch response. """ ValidationHelper.validate_es_query_type(query) return self.connection.delete_by_query( index=index, doc_type=query.doc_type, body=query.to_query_dict(), )