mirror of
https://github.com/langchain-ai/langchain-postgres.git
synced 2026-07-16 01:33:18 -04:00
Array inclusion filter operation #58
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @sjjpo2002 on GitHub (Dec 4, 2024).
I want to be able to filter vector search results by records that include a specific item in an array type field. The current filtering operators do not support doing the element-wise inclusion test I need. The supported operators are listed here:
None of the operators from that list does exactly the inclusion test for a list of text elements. The closest is the
$likeoperator which only works if the field is text. It doesn't work for array type because it tries to do an exact match for the entire array rather than looking into the elements inside.To reproduce this issue you can use this sample code.
First let's define the schema and push some sample data in:
Now I use the following code to retrive data from the collection we just ingested:
I have implemented another operator for array element-wise inclusion test which will fix this issue. But, I want to report this issue first for your review before creating a PR.
Thanks for reading.