langchain icon indicating copy to clipboard operation
langchain copied to clipboard

Adds 'IN' metadata filter for pgvector for checking set presence

Open jadespanning opened this issue 2 years ago • 4 comments

Adds "IN" metadata filter for pgvector to all checking for set presence

PGVector currently supports metadata filters of the form:

{"filter": {"key": "value"}}

which will return documents where the "key" metadata field is equal to "value".

This PR adds support for metadata filters of the form:

{"filter": {"key": { "IN" : ["list", "of", "values"]}}}

Other vector stores support this via an "$in" syntax. I chose to use "IN" to match postgres' syntax, though happy to switch. Tested locally with PGVector and ChatVectorDBChain.

@dev2049

jadespanning avatar May 17 '23 22:05 jadespanning

nice! could we add a simple integration test?

dev2049 avatar May 17 '23 23:05 dev2049

Added an integration test!

jadespanning avatar May 18 '23 00:05 jadespanning

ready for merge, maintain needs to resolve linting issues

eyurtsev avatar May 19 '23 14:05 eyurtsev

https://github.com/hwchase17/langchain/pull/4982 with lint fixes

eyurtsev avatar May 19 '23 14:05 eyurtsev

landed #4982 !

dev2049 avatar May 19 '23 20:05 dev2049

@jadespanning please add this to docs

devilankur18 avatar Jul 27 '23 07:07 devilankur18