How to perform a query that returns all the objects that don't have a specific value in an array property?

Hey Folks!

I have 4 objects in my schema:

{
....
keywords: ['keyword1', 'keyword2', 'keyword3']
....
}
{
....
keywords: ['keyword2', 'keyword3']
....
}
{
....
keywords: []
....
}
{
....
otherProperty: 'otherValue' // This object doesn't have the property 'keywords'
....
}

I want to perform a query that returns all the objects that don’t have the keyword ‘keyword1’ in the property ‘keywords’. I expect to get objects 2, 3, and 4.

I tried with the following query, but it doesn’t work:

{
  Get {
    Test (
      where: {
        operator: NotEqual
        path:["keywords"]
        valueText:"keyword1"
      }
    ){
      keywords
    }
  }
}

It just returns objects 1 and 2.

Hi @fzaffarana,

The problem here is actually with finding an object for which a given text element does Not appear in an array; returning object #4 is secondary and could be done with a nested where filter.

As of now, Weaviate doesn’t support finding objects in which the specified array does not contain an element. Your GraphQL query arguably returns object #1 as a correct result because keyword2 (and keyword3) in the array are NotEqual to keyword1.

You may want to follow this forum thread and the associated GitHub issue: