Skip to content

Filters¤

DateRangeQuery ¤

Bases: DateRangeQuery

Source code in src/couchbase_haystack/document_stores/filters.py
class DateRangeQuery(search.DateRangeQuery):
    @property
    def inclusive_start(self) -> Optional[bool]:
        return self._json_.get("inclusive_start", None)

    @inclusive_start.setter
    def inclusive_start(
        self, value  # type: bool
    ) -> None:
        self.set_prop("inclusive_start", value)

    @property
    def inclusive_end(self) -> Optional[bool]:
        return self._json_.get("inclusive_end", None)

    @inclusive_end.setter
    def inclusive_end(
        self, value  # type: bool
    ) -> None:
        self.set_prop("inclusive_end", value)

NumericRangeQuery ¤

Bases: NumericRangeQuery

Source code in src/couchbase_haystack/document_stores/filters.py
class NumericRangeQuery(search.NumericRangeQuery):
    @property
    def inclusive_min(self) -> Optional[bool]:
        return self._json_.get("inclusive_min", None)

    @inclusive_min.setter
    def inclusive_min(
        self, value  # type: bool
    ) -> None:
        self.set_prop("inclusive_min", value)

    @property
    def inclusive_max(self) -> Optional[bool]:
        return self._json_.get("inclusive_max", None)

    @inclusive_max.setter
    def inclusive_max(
        self, value  # type: bool
    ) -> None:
        self.set_prop("inclusive_max", value)

_normalize_filters ¤

_normalize_filters(filters: Dict[str, Any]) -> SearchQuery

Converts Haystack filters in Couchbase compatible filters.

Source code in src/couchbase_haystack/document_stores/filters.py
def _normalize_filters(filters: Dict[str, Any]) -> SearchQuery:
    """
    Converts Haystack filters in Couchbase compatible filters.
    """
    if not isinstance(filters, dict):
        msg = "Filters must be a dictionary"
        raise FilterError(msg)

    if "field" in filters:
        return _parse_comparison_condition(filters)
    return _parse_logical_condition(filters)