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

[Feature Request] Add "Not" operator in filter to support "Not Like" etc. in Get queries #3683

Open
paulcalcraft opened this issue Oct 27, 2023 · 11 comments · May be fixed by #4924 or #4310
Open

[Feature Request] Add "Not" operator in filter to support "Not Like" etc. in Get queries #3683

paulcalcraft opened this issue Oct 27, 2023 · 11 comments · May be fixed by #4924 or #4310

Comments

@paulcalcraft
Copy link

paulcalcraft commented Oct 27, 2023

It looks like a previously faulty not operator was removed: #3360

But I can't see any way to filter a search by excluding some matching criteria. For example, I want to exclude embedded chunks that are from a particular domain name, so I want to essentially invert this Like:

const response = await client.graphql
  .get()
  .withClassName('Snippet')
  .withFields('text')
  .withWhere({
    path: ['url'],
    operator: 'Like',
    valueText: 'https://example.org*',
  })
  .do();
console.log(response);

So we'd be able to add a Not operator like this:

const response = await client.graphql
  .get()
  .withClassName('Snippet')
  .withFields('text')
  .withWhere({
                operator: 'Not',
                operands: [{
                    path: ['url'],
                    operator: 'Like',
                    valueText: 'https://example.org*',
                }],
            })
  .do();
console.log(response);

Given the implementation of Like etc. (https://github.com/weaviate/weaviate/blob/b5490142fa6cea9a6212e77055db7479e69760b7/adapters/repos/db/inverted/row_reader.go#L194C24-L194C24) it might actually be easier to implement as a new operator called NotLike, rather than a general purpose Not? I haven't looked too far into it.

In any case, it might be worth adding a note to the filter documentation to say that a Not operator isn't currently supported because it took me quite a lot of digging to confirm that I wasn't just missing something. (And I might still be!)

@etiennedi
Copy link
Member

Thanks for the request. Seems very related to #3319 which would likely act as a basis for this. Please upvote that one as well, to express your interest.

@thearchitector
Copy link

thearchitector commented Nov 29, 2023

For posterity (i upvoted as well), being able to negate arbitrary filters would be incredibly useful / necessary for complex logic, so i fully support this as a feature.

@alberto-bracci
Copy link

Any update on this feature request?

@litlig litlig linked a pull request Feb 26, 2024 that will close this issue
4 tasks
@junbetterway
Copy link

junbetterway commented May 10, 2024

Any updates on this? Also, will this support negations like WHERE prop NOT ContainsAny (:excludedValues) ? Thanks!

@philipvollet
Copy link

Hi community, we're adding a bounty to this feature request /bounty $300

Related issues for more information:
#4231

Copy link

algora-pbc bot commented May 13, 2024

💎 $300 bounty • Weaviate

Steps to solve:

  1. Start working: Comment /attempt #3683 with your implementation plan
  2. Submit work: Create a pull request including /claim #3683 in the PR body to claim the bounty
  3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

Additional opportunities:

Thank you for contributing to weaviate/weaviate!

Add a bountyShare on socials

Attempt Started (GMT+0) Solution
🔴 @Ahmadkhan02 May 14, 2024, 7:44:10 AM WIP
🟢 @varshith257 May 14, 2024, 8:55:01 PM #4924
🟢 @litlig #4310

@Ahmadkhan02
Copy link

Ahmadkhan02 commented May 14, 2024

/attempt #3683

refactor @litlig 's code

Algora profile Completed bounties Tech Active attempts Options
@Ahmadkhan02 1 bounty from 1 project
TypeScript, Jupyter Notebook
Cancel attempt

@Ahmadkhan02 Ahmadkhan02 mentioned this issue May 14, 2024
@varshith257
Copy link

varshith257 commented May 14, 2024

/attempt #3683

@varshith257 varshith257 linked a pull request May 14, 2024 that will close this issue
4 tasks
Copy link

algora-pbc bot commented May 14, 2024

💡 @varshith257 submitted a pull request that claims the bounty. You can visit your bounty board to reward.

Copy link

algora-pbc bot commented May 14, 2024

💡 @litlig submitted a pull request that claims the bounty. You can visit your bounty board to reward.

@litlig
Copy link
Contributor

litlig commented May 14, 2024

Hey Weaviate team, I drafted a solution for this a few weeks ago, but it has not been reviewed. Please take a look #4310

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants