From 8dc7060f5c48ca42e15b1baa7236f0da3fcf801c Mon Sep 17 00:00:00 2001 From: cmuhao Date: Tue, 16 Apr 2024 00:13:46 -0700 Subject: [PATCH] update doc Signed-off-by: cmuhao --- docs/reference/online-stores/postgres.md | 28 ++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docs/reference/online-stores/postgres.md b/docs/reference/online-stores/postgres.md index 3885867dd26..57d6366f830 100644 --- a/docs/reference/online-stores/postgres.md +++ b/docs/reference/online-stores/postgres.md @@ -30,6 +30,8 @@ online_store: sslkey_path: /path/to/client-key.pem sslcert_path: /path/to/client-cert.pem sslrootcert_path: /path/to/server-ca.pem + pgvector_enabled: false + vector_len: 512 ``` {% endcode %} @@ -60,3 +62,29 @@ Below is a matrix indicating which functionality is supported by the Postgres on | collocated by entity key | no | To compare this set of functionality against other online stores, please see the full [functionality matrix](overview.md#functionality-matrix). + +## PGVector +The Postgres online store supports the use of [PGVector](https://pgvector.dev/) for storing feature values. +To enable PGVector, set `pgvector_enabled: true` in the online store configuration. +The `vector_len` parameter can be used to specify the length of the vector. The default value is 512. + +Then you can use `retrieve_online_documents` to retrieve the top k closest vectors to a query vector. + +{% code title="python" %} +```python +from feast import FeatureStore +from feast.infra.online_stores.postgres import retrieve_online_documents + +feature_store = FeatureStore(repo_path=".") + +query_vector = [0.1, 0.2, 0.3, 0.4, 0.5] +top_k = 5 + +feature_values = retrieve_online_documents( + feature_store=feature_store, + feature_view_name="document_fv:embedding_float", + query_vector=query_vector, + top_k=top_k, +) +``` +{% endcode %} \ No newline at end of file