Skip to content

Commit

Permalink
fix: ast normalize comments and add test for implicit OR operator fre…
Browse files Browse the repository at this point in the history
…e-text expressions
  • Loading branch information
fschade committed Aug 28, 2023
1 parent 6a1820f commit 61a00a5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion services/search/pkg/query/kql/normalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var operatorNodeOr = ast.OperatorNode{Base: &ast.Base{Loc: &ast.Location{Source:
// https://learn.microsoft.com/en-us/sharepoint/dev/general-development/keyword-query-language-kql-syntax-reference#constructing-free-text-queries-using-kql
// If there are multiple free-text expressions without any operators in between them, the query behavior is the same as using the AND operator.
// "John Smith" "Jane Smith"
// This functionally is the same as using the OR Boolean operator, as follows:
// This functionally is the same as using the AND Boolean operator, as follows:
// "John Smith" AND "Jane Smith"
//
// https://learn.microsoft.com/en-us/sharepoint/dev/general-development/keyword-query-language-kql-syntax-reference#using-multiple-property-restrictions-within-a-kql-query
Expand Down
12 changes: 12 additions & 0 deletions services/search/pkg/query/kql/normalize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ func TestNormalizeNodes(t *testing.T) {
&ast.StringNode{Key: "author", Value: "Jane Smith"},
},
},
{
name: "no key explicit AND",
givenNodes: []ast.Node{
&ast.StringNode{Value: "John Smith"},
&ast.StringNode{Value: "Jane Smith"},
},
expectedNodes: []ast.Node{
&ast.StringNode{Value: "John Smith"},
&ast.OperatorNode{Value: "AND"},
&ast.StringNode{Value: "Jane Smith"},
},
},
{
name: "same key explicit AND",
givenNodes: []ast.Node{
Expand Down

0 comments on commit 61a00a5

Please sign in to comment.