I have been trying to wrap my head around this for a while and thought of asking the community if this is a BUG and needs to be reported.
Let’s imagine we have a simple set of documents in weaviate collection, that can be defined for simplicity as this list:
test_documents = [
{"document_name": "test_document_1.txt", "content": "This is the first test document."},
{"document_name": "test_document_2.txt", "content": "Another document for testing."},
{"document_name": "project_plan.txt", "content": "This document contains the project plan."},
{"document_name": "summary_report.txt", "content": "The summary of all reports."},
{"document_name": "test_document_3.txt", "content": "This document is for additional tests."},
]
We then have this GraphQL query:
{
Aggregate {
Test_collection(
where: {
operator: And,
operands: [
{
operator: Or,
operands: [
{path: ["document_name"], operator: Like, valueText: "*test*"},
{path: ["content"], operator: NotEqual, valueText: "This is the first test document."}
]
},
{
operator: Or,
operands: [
{path: ["document_name"], operator: Equal, valueText: "project_plan.txt"},
{path: ["content"], operator: Like, valueText: "*project*"}
]
}
]
},
tenant: "test_collection"
) {
meta {
count
}
}
}
}
The query should be returning 1 document (project_plan.txt) but it is returning 0.
I took This logical approach when breaking down the query and running the operands separately.
The first part matches all 5 documents:
operator: Or,
operands: [
{path: ["document_name"], operator: Like, valueText: "*test*"},
{path: ["content"], operator: NotEqual, valueText: "This is the first test document."}
]
The second part matches only 1 document:
operator: Or,
operands: [
{path: ["document_name"], operator: Equal, valueText: "project_plan.txt"},
{path: ["content"], operator: Like, valueText: "*project*"}
]
The AND operator between the filters for all 5 documents and 1 document should be returning 1 document as a result.
Am I missing something here?