Skip to main content

agrag.retrieval.filters.SearchFilters

Bases: BaseModel

Constraints applied across every retrieval method in one call.

Attributes:

  • labels (list[str]) – Entity labels a result must have, when searching entities.
  • relation_types (list[str]) – Relation types a traversal can cross.
  • document_ids (list[str]) – Restrict results to entities and chunks from these source documents.
  • properties (dict[str, Any]) – Exact-match property filters, applied identically to vector-store payload filters and Cypher WHERE clauses.

Functions:

document_ids​

document_ids: list[str] = Field(default_factory=list)

labels​

labels: list[str] = Field(default_factory=list)

properties​

properties: dict[str, Any] = Field(default_factory=dict)

relation_types​

relation_types: list[str] = Field(default_factory=list)

to_cypher_where​

to_cypher_where(node_var:str = 'node') -> tuple[str, dict[str, Any]]

Return a parameterized WHERE clause fragment.

Labels are emitted as native Cypher node labels (node:Label) rather than property filters, since Neo4j represents entity types as labels on nodes. Document-id and property filters go through filter_clause as before.

Parameters:

  • node_var (str) – The Cypher variable bound to the node.

Returns:

  • tuple[str, dict[str, Any]] – The WHERE clause text and parameters dict.

to_payload_filter​

to_payload_filter() -> dict[str, Any]

Return a flat-dict filter for VectorStore search calls.

Labels become a label payload key, which is how a VectorStore records the graph label a record came from. A GraphStore holds labels on the node itself, not as a property, so the native path uses to_property_filter instead and selects labels by the index it searches.

Returns:

  • dict[str, Any] – A dict suitable for VectorStore.search/hybrid_search
  • dict[str, Any] – filters parameter.

to_property_filter​

to_property_filter() -> dict[str, Any]

Return a flat-dict filter over node properties only.

Excludes labels, which are node labels rather than properties on every graph backend this project supports.

Returns:

  • dict[str, Any] – A dict of property name to expected value, where a list
  • dict[str, Any] – value means any of.