Skip to content
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

Issue with JSONPath with a in array check #247

Open
raghavendracs opened this issue Oct 28, 2023 · 4 comments
Open

Issue with JSONPath with a in array check #247

raghavendracs opened this issue Oct 28, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@raghavendracs
Copy link

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?

@danielchalef
Copy link
Member

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 danielchalef added the bug Something isn't working label Oct 29, 2023
@raghavendracs
Copy link
Author

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
Copy link
Author

Any luck with this @danielchalef ?

@danielchalef
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants