def static_query(high_price=500, delay_days=35): with DocumentStoreHolder.get_store().open_session() as session: query = list( session.query(index_name="CostlyOrders").where_greater_than( "Price", high_price).and_also().where_greater_than( "Delay", Utils.timedelta_tick(timedelta(days=delay_days)))) return query[0] if query else None
def static_query(high_price=500, delay_days=35): with DocumentStoreHolder.get_store().open_session() as session: query = list( session.query(index_name="CostlyOrders"). where_greater_than("Price", high_price). and_also(). where_greater_than("Delay", Utils.timedelta_tick(timedelta(days=delay_days)))) return query[0] if query else None
def where_between(self, field_name, start, end): if isinstance(start, timedelta): start = Utils.timedelta_tick(start) if isinstance(end, timedelta): end = Utils.timedelta_tick(end) value = start or end if self.session.conventions.uses_range_type(value) and not field_name.endswith("_Range"): sort_hint = self.session.conventions.get_default_sort_option(type(value).__name__) if sort_hint: field_name = "{0}_Range".format(field_name) if sys.version_info.major > 2: if value > 2147483647: sort_hint = self.session.conventions.get_default_sort_option("long") self._sort_hints.add("SortHint-{0}={1}".format(field_name, sort_hint)) lucene_text = self._lucene_builder([start, end], action="between") self.query_builder += "{0}:{1}".format(field_name, lucene_text) return self