Skip to content
Snippets Groups Projects
Unverified Commit ac0fc6f0 authored by CinematicDev's avatar CinematicDev Committed by GitHub
Browse files

Update supabase vecs metadata filter function to support multiple fields (#10133)


* Update vectors to filter to use updated vecs query language for multi-field query searches

* Initial commit

* cr

---------

Co-authored-by: default avatarHaotian Zhang <socool.king@gmail.com>
parent 2b2d62b2
Branches
Tags
No related merge requests found
import logging
import math
from collections import defaultdict
from typing import Any, List
from llama_index.constants import DEFAULT_EMBEDDING_DIM
......@@ -74,9 +75,13 @@ class SupabaseVectorStore(VectorStore):
def _to_vecs_filters(self, filters: MetadataFilters) -> Any:
"""Convert llama filters to vecs filters. $eq is the only supported operator."""
vecs_filter = {}
vecs_filter = defaultdict(list)
filter_cond = f"${filters.condition}"
for f in filters.legacy_filters():
vecs_filter[f.key] = {"$eq": f.value}
sub_filter = {}
sub_filter[f.key] = {"$eq": f.value}
vecs_filter[filter_cond].append(sub_filter)
return vecs_filter
def add(self, nodes: List[BaseNode], **add_kwargs: Any) -> List[str]:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment