-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[ENH] add not contains filter to where clause #1469
Conversation
Reviewer ChecklistPlease leverage this checklist to ensure your code review is thorough before approving Testing, Bugs, Errors, Logs, Documentation
System Compatibility
Quality
|
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.
One nit from me -- this looks great (and lots of users have been asking for it)!
if "%" in expr or "_" in expr: | ||
expr = expr.replace("%", ".").replace("_", ".") | ||
return doc and re.search(expr, doc) is None | ||
return doc and expr not in doc |
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.
Nit: I don't love that we check doc and ...
for this if-branch but not the above branch.
Could we instead do one of:
- Do an
if not doc
check above so both branches benefit from it - Also do the
doc and ...
check in thekey == "$contains"
branch - Not do the check here (not possible if the typechecker is complaining)?
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.
I will add the check above the if-branch.
this check exists because SQLite 'not like' does not return rows for empty or NULL strings. In this case, both "contains" and "not_contains" will not return NULL or empty strings. We can also argue that "not_contains" should return all NULL and empty strings.
@@ -309,7 +317,7 @@ def test_boolean_metadata(api: ServerAPI) -> None: | |||
|
|||
|
|||
def test_get_empty(api: ServerAPI) -> None: | |||
"""Tests that calling get() with empty filters returns nothing""" | |||
"""Tests that calling get() with empty filters returns Fhing""" |
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.
"""Tests that calling get() with empty filters returns Fhing""" | |
"""Tests that calling get() with empty filters returns nothing""" |
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.
whoops, will fix this
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.
We also have to update the documentation, can you link to a docs PR ?
We will also have to add this to the js client - i think its typed - cc @jeffchuber |
@weiligu, this looks great. Thank you. Do you mind also including an example of this the operator is used in either a new or one of the existing notebooks under https://github.com/chroma-core/chroma/blob/main/examples/basic_functionality/. Perhaps in where_filtering.ipynb |
Description of changes
Summarize the changes made by this PR.
There are some formatting changes included
Test plan
Documentation Changes
will update [docs]user-guide
added an example to Where Filtering