Hello,
In according to that code:
|
for k, v := range whereDocument { |
|
switch k { |
|
case "$contains": |
|
if !strings.Contains(document.Content, v) { |
|
return false |
|
} |
|
case "$not_contains": |
|
if strings.Contains(document.Content, v) { |
|
return false |
|
} |
|
default: |
|
// No handling (error) required because we already validated the |
|
// operators. This simplifies the concurrency logic (no err var |
|
// and lock, no context to cancel). |
|
} |
|
} |
we can create only simply filter, for example:
whereDocument =map[string]string{
"$contains":"word1",
"$not_contains", "word2",
}
but if we invert key-value, then we can more complex query. Example of code:
for k, v := range whereDocument {
switch v { // <----
case "$contains":
if !strings.Contains(document.Content, k) { // <----
return false
}
case "$not_contains":
if strings.Contains(document.Content, k) { // <----
return false
}
default:
// No handling (error) required because we already validated the
// operators. This simplifies the concurrency logic (no err var
// and lock, no context to cancel).
}
}
Thank you.
Hello,
In according to that code:
chromem-go/query.go
Lines 145 to 160 in f63964a
we can create only simply filter, for example:
but if we invert key-value, then we can more complex query. Example of code:
Thank you.