def stream(self, batch): response = self.post(batch) try: for i, result_data in grouped(response): result = JobResult.hydrate(assembled(result_data), batch) log.info("<<< %s", result) yield result finally: response.close()
def stream(self, batch): """ Execute a collection of jobs and yield results as received. :arg batch: A :class:`.Batch` of jobs. :rtype: generator """ response = self.post(batch) try: for i, result_data in grouped(response): result = JobResult.hydrate(assembled(result_data), batch) log.info("< %s", result) yield result finally: response.close()
def get(self, key, value): """ Fetch a list of all entities from the index which are associated with the `key`:`value` pair supplied:: # obtain a reference to the "People" node index and # get all nodes where `family_name` equals "Smith" people = graph.get_or_create_index(neo4j.Node, "People") smiths = people.get("family_name", "Smith") .. """ return [ self.graph.hydrate(assembled(result)) for i, result in grouped(self._searcher.expand(key=key, value=value).get()) ]
def get(self, key, value): """ Fetch a list of all entities from the index which are associated with the `key`:`value` pair supplied:: # obtain a reference to the "People" node index and # get all nodes where `family_name` equals "Smith" people = graph.get_or_create_index(neo4j.Node, "People") smiths = people.get("family_name", "Smith") .. """ return [ self.graph.hydrate(assembled(result)) for i, result in grouped( self._searcher.expand(key=key, value=value).get()) ]
def query(self, query): """ Query the index according to the supplied query criteria, returning a list of matched entities:: # obtain a reference to the "People" node index and # get all nodes where `family_name` equals "Smith" people = graph.get_or_create_index(neo4j.Node, "People") s_people = people.query("family_name:S*") The query syntax used should be appropriate for the configuration of the index being queried. For indexes with default configuration, this should be Apache Lucene query syntax. """ resource = self._query_template.expand(query=query) for i, result in grouped(resource.get()): yield self.graph.hydrate(assembled(result))
def _query_with_score(self, query, order): resource = self._query_template.expand(query=query, order=order) for i, result in grouped(resource.get()): meta = assembled(result) yield self.graph.hydrate(meta), meta["score"]
def __iter__(self): for i, response in grouped(self.__response): yield BatchResponse.hydrate(assembled(response), self.body_hydrator) self.close()