Skip to content

Commit fc121c3

Browse files
feat: Updating retrieve online documents v2 to work for other fields for sq… (feast-dev#5082)
* Updating retrieve online documents v2 to work for other fields for sqlite Signed-off-by: Francisco Javier Arceo <[email protected]> * updating tests...not working entirely yet but close Signed-off-by: Francisco Javier Arceo <[email protected]> * bug fix for addition of new features Signed-off-by: Francisco Javier Arceo <[email protected]> * updated to implement full text search Signed-off-by: Francisco Javier Arceo <[email protected]> --------- Signed-off-by: Francisco Javier Arceo <[email protected]>
1 parent 1705922 commit fc121c3

File tree

12 files changed

+504
-136
lines changed

12 files changed

+504
-136
lines changed

sdk/python/feast/feature_server.py

+2
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class GetOnlineFeaturesRequest(BaseModel):
7575
features: Optional[List[str]] = None
7676
full_feature_names: bool = False
7777
query_embedding: Optional[List[float]] = None
78+
query_string: Optional[str] = None
7879

7980

8081
def _get_features(request: GetOnlineFeaturesRequest, store: "feast.FeatureStore"):
@@ -195,6 +196,7 @@ async def retrieve_online_documents(
195196
entity_rows=request.entities,
196197
full_feature_names=request.full_feature_names,
197198
query=request.query_embedding,
199+
query_string=request.query_string,
198200
)
199201

200202
response = await run_in_threadpool(

sdk/python/feast/feature_store.py

+5
Original file line numberDiff line numberDiff line change
@@ -1867,6 +1867,7 @@ def retrieve_online_documents_v2(
18671867
top_k: int,
18681868
features: List[str],
18691869
distance_metric: Optional[str] = "L2",
1870+
query_string: Optional[str] = None,
18701871
) -> OnlineResponse:
18711872
"""
18721873
Retrieves the top k closest document features. Note, embeddings are a subset of features.
@@ -1878,6 +1879,7 @@ def retrieve_online_documents_v2(
18781879
query: The query to retrieve the closest document features for.
18791880
top_k: The number of closest document features to retrieve.
18801881
distance_metric: The distance metric to use for retrieval.
1882+
query_string: The query string to retrieve the closest document features using keyword search (bm25).
18811883
"""
18821884
if isinstance(query, str):
18831885
raise ValueError(
@@ -1919,6 +1921,7 @@ def retrieve_online_documents_v2(
19191921
query,
19201922
top_k,
19211923
distance_metric,
1924+
query_string,
19221925
)
19231926

19241927
def _retrieve_from_online_store(
@@ -1988,6 +1991,7 @@ def _retrieve_from_online_store_v2(
19881991
query: List[float],
19891992
top_k: int,
19901993
distance_metric: Optional[str],
1994+
query_string: Optional[str],
19911995
) -> OnlineResponse:
19921996
"""
19931997
Search and return document features from the online document store.
@@ -2003,6 +2007,7 @@ def _retrieve_from_online_store_v2(
20032007
query=query,
20042008
top_k=top_k,
20052009
distance_metric=distance_metric,
2010+
query_string=query_string,
20062011
)
20072012

20082013
entity_key_dict: Dict[str, List[ValueProto]] = {}

sdk/python/feast/feature_view.py

+4
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ def __init__(
192192
else:
193193
features.append(field)
194194

195+
assert len([f for f in features if f.vector_index]) < 2, (
196+
f"Only one vector feature is allowed per feature view. Please update {self.name}."
197+
)
198+
195199
# TODO(felixwang9817): Add more robust validation of features.
196200
cols = [field.name for field in schema]
197201
for col in cols:

sdk/python/feast/infra/online_stores/milvus_online_store/milvus.py

+1
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ def retrieve_online_documents_v2(
463463
embedding: List[float],
464464
top_k: int,
465465
distance_metric: Optional[str] = None,
466+
query_string: Optional[str] = None,
466467
) -> List[
467468
Tuple[
468469
Optional[datetime],

sdk/python/feast/infra/online_stores/online_store.py

+2
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ def retrieve_online_documents_v2(
439439
embedding: List[float],
440440
top_k: int,
441441
distance_metric: Optional[str] = None,
442+
query_string: Optional[str] = None,
442443
) -> List[
443444
Tuple[
444445
Optional[datetime],
@@ -456,6 +457,7 @@ def retrieve_online_documents_v2(
456457
requested_features: The list of features whose embeddings should be used for retrieval.
457458
embedding: The embeddings to use for retrieval.
458459
top_k: The number of documents to retrieve.
460+
query_string: The query string to search for using keyword search (bm25) (optional)
459461
460462
Returns:
461463
object: A list of top k closest documents to the specified embedding. Each item in the list is a tuple

0 commit comments

Comments
 (0)