def results(self): if not self.batch_param_values: yield from search_generator(self._build_new_request([]))['@graph'] for batched_values in self._make_batched_values_from_batch_param_values( ): batched_params = self._make_batched_params_from_batched_values( batched_values) request = self._build_new_request(batched_params) yield from search_generator(request)['@graph']
def test_search_views_search_generator(index_workbook, dummy_request, threadlocals): from types import GeneratorType dummy_request.environ['QUERY_STRING'] = ( 'type=*&limit=all' ) from encoded.search_views import search_generator r = search_generator(dummy_request) assert '@graph' in r assert len(r.keys()) == 1 assert isinstance(r['@graph'], GeneratorType) hits = [dict(h) for h in r['@graph']] assert len(hits) > 800 assert '@id' in hits[0]
def test_search_generator(index_workbook, threadlocals, dummy_request): from snovault.elasticsearch.searches.parsers import ParamsParser from snovault.elasticsearch import ELASTIC_SEARCH from elasticsearch import Elasticsearch from types import GeneratorType dummy_request.environ['QUERY_STRING'] = ('type=*&limit=all') dummy_request.registry[ELASTIC_SEARCH] = Elasticsearch(port=9201) from encoded.search_views import search_generator r = search_generator(dummy_request) assert '@graph' in r assert len(r.keys()) == 1 assert isinstance(r['@graph'], GeneratorType) hits = [dict(h) for h in r['@graph']] assert len(hits) > 800 assert '@id' in hits[0]
def generate_rows(): yield format_header(header) yield format_row(header) for item in search_generator(request)['@graph']: values = [lookup_column_value(item, path) for path in columns] yield format_row(values)