Search code examples
weaviate

where filter with multiple operators in Weaviate


I wonder is there is a way of querying inverted index by using complex logical operations, like:

find "some_text" from property 'property1' OR 'property2' AND created_at before 'date'

where filter only accepts one operator according to documentation.


Solution

  • Absolutely, it's explained here

    An example based on your question would be:

    {
      Get {
        ClassName(
          where: {
            operator: And
            operands: [{
              operator: Or
              operands: [{
                path: ["property"]
                operator: Like
                valueString: "property1"
              }, {
                path: ["property"]
                operator: Like
                valueString: "property2"
              }]
            }, {
              path: ["_creationTimeUnix"]
              operator: LessThan
              valueString: "1664505080008"
            }]
          }
        ) {
          property
          _additional {
            creationTimeUnix
          }
        }
      }
    }
    

    PS:
    This indeed becomes -as you write- a complex filter ;)