def search(self, q, models=None, order_by=RELEVANCE, limit=None, offset=None): if len(q) == 0: return SearchResults(q, [], 0, lambda x: x) original_query = q q = convert_query(original_query, SolrQueryConverter) if models is not None: models_clause = self._models_query(models) final_q = '(%s) AND (%s)' % (q, models_clause) else: final_q = q kwargs = {} if order_by != RELEVANCE: if order_by[0] == '-': kwargs['sort'] = '%s desc' % order_by[1:] else: kwargs['sort'] = '%s asc' % order_by if limit is not None: kwargs['rows'] = limit if offset is not None: kwargs['start'] = offset results = self.conn.search(final_q, **kwargs) return SearchResults(final_q, iter(results.docs), results.hits, self._result_callback)
def search(self, query, models=None, order_by=RELEVANCE, limit=25, offset=0): model = models[0] cond = Condition() cond.set_phrase(query) for field, value in attrs.items(): operator = self._get_eq_operator(model, field) attr_clause = '%s %s %s' % (field, operator, value) cond.add_attr(attr_clause) # restrict the search results to the given models models_clause = ' '.join([django_ct(model) for model in models]) model_clause = '%s STROREQ %s' % (CT_ATTR, models_clause) cond.add_attr(model_clause) # handle ordering of the search results if order_by != RELEVANCE: cond.set_order(self._build_order_clause(model, order_by)) cond.set_max(limit) cond.set_skip(offset) node_result = self.node.search(cond) return SearchResults(query, node_result.docs, self._result_callback)
def search(self, q, models=None, order_by=RELEVANCE, limit=None, offset=None): return SearchResults(q, [], 0, lambda r: r)
def search(self, query, models=None, order_by=RELEVANCE, limit=25, offset=0): db = self._read_only_db() # TODO: implement me return SearchResults(query, results, self._result_callback)
def _get_search_results(self, q, hits, limit, offset): """Return a SearchResults object for these hits.""" iterator = iter(hits) if limit is not None and offset is not None: iterator = islice(iterator, offset, limit + offset) elif limit is not None: iterator = islice(iterator, 0, limit) elif offset is not None: iterator = islice(iterator, offset) return SearchResults(q, iterator, self._resolve_hit)
def search(query, models=None): """ Returns a SearchResults object containing the results. """ return SearchResults(SearchQuery(query, models))