zep icon indicating copy to clipboard operation
zep copied to clipboard

Issue with JSONPath with a in array check

Open raghavendracs opened this issue 2 years ago • 4 comments

Describe the bug I am trying to use a filter clause as follows

metadata_query = {"where": { "jsonpath": "[$[*] ? (@.source in ['a', 'b'])]"}} retriever = vs.as_retriever( search_kwargs={"metadata": metadata_query})

To Reproduce just create a ZepVectorStore and try the above

Expected behavior able to define a retriever which will only fetch documents which have source as either a or b

Logs Am getting this error

zep_python.exceptions.APIError: API error: {'status_code': 500, 'message': 'failed to search collection: failed to execute search: error executing search: error executing query: error scanning query ERROR: syntax error at or near "[" of jsonpath input (SQLSTATE=42601)\n'}

The JSONPath expression is fine as far as I can see. So is that I can only filter simple ==, != etc based checks?

raghavendracs avatar Oct 28 '23 23:10 raghavendracs

Thanks for reporting. While we investigate, would you like to use Zep filter boolean logic here rather than an in operation? I recognize this may not be helpful if the array is large.

https://docs.getzep.com/sdk/search_query/#combining-multiple-jsonpath-filters-using-boolean-logic

danielchalef avatar Oct 29 '23 01:10 danielchalef

Thanks @danielchalef for your quick feedback. Am trying to test out Zep for a use case that I have, so will wait for your response while I continue. Needless to say wanted to be able to check against a variable which has a List of filenames that user provides to run a query against.

raghavendracs avatar Oct 29 '23 08:10 raghavendracs

Any luck with this @danielchalef ?

raghavendracs avatar Nov 08 '23 11:11 raghavendracs

Hey @raghavendracs unfortunately I've not had time to investigate. We use Postgres' JSONPath flavor. If the in syntax is not supported by Postgres, it won't work with Zep:

https://www.postgresql.org/docs/current/functions-json.html#FUNCTIONS-SQLJSON-PATH

danielchalef avatar Nov 08 '23 22:11 danielchalef