-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add filter_policy to pgvector integration #820
Conversation
...ons/pgvector/src/haystack_integrations/components/retrievers/pgvector/embedding_retriever.py
Outdated
Show resolved
Hide resolved
@@ -139,7 +144,11 @@ def run( | |||
|
|||
:returns: List of Documents similar to `query_embedding`. | |||
""" | |||
filters = filters or self.filters | |||
if self.filter_policy == "merge" and filters: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the docstrings of the run
method, I would mention that the way runtime filters are applied depends on the filter_policy
chosen at document store initialization.
Good feedback, thanks @anakin87 , will apply across the board |
…rievers/pgvector/embedding_retriever.py Co-authored-by: Stefano Fiorucci <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also add a test as requested/done in #823 (comment)?
Yes, already on it - for all PRs 😓 |
I understand your pain. |
@anakin87 we need to use the already released https://github.com/deepset-ai/haystack/blob/main/haystack/document_stores/types/filter_policy.py instead of literal, across the board as well. I'll add that change here. |
Please delay review until a new patch release of 2.2.x is released. We need these two PRs to be included in a patch release first. |
Ready for review now @anakin87
|
Stefano recommended one more small improvement. Please hold your review until a new commit with it is added here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please incorporate the suggestions and merge 🙂
...ons/pgvector/src/haystack_integrations/components/retrievers/pgvector/embedding_retriever.py
Outdated
Show resolved
Hide resolved
...tions/pgvector/src/haystack_integrations/components/retrievers/pgvector/keyword_retriever.py
Outdated
Show resolved
Hide resolved
...tions/pgvector/src/haystack_integrations/components/retrievers/pgvector/keyword_retriever.py
Outdated
Show resolved
Hide resolved
…rievers/pgvector/keyword_retriever.py Co-authored-by: Stefano Fiorucci <[email protected]>
…rievers/pgvector/embedding_retriever.py Co-authored-by: Stefano Fiorucci <[email protected]>
…rievers/pgvector/keyword_retriever.py Co-authored-by: Stefano Fiorucci <[email protected]>
@anakin87 one last look 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
Why:
Adds flexible filtering options to pgvector integration. By introducing a filter policy option (
replace
ormerge
), developers can now control how runtime filters are applied relative to initialization time filters.filter_policy
init parameter to all retrievers #780What:
filter_policy
parameter with optionsreplace
andmerge
across multiple retrievers to control filter behavior dynamically.How can it be used:
Dynamic Filter Behavior Adjustment: Users can decide whether to completely override the initial filters set during the retriever's initialization (
replace
) or merge them with runtime filters, with the latter taking precedence (merge
).Complex Search Scenarios:
merge
option allows for an additive approach.replace
option offers a clean slate for filters at runtime.How did you test it:
replace
andmerge
scenarios for thefilter_policy
parameter.