-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from Trendyol/feature/missing_match_parameters
feature: Add remaining `Match Query` parameters
- Loading branch information
Showing
7 changed files
with
464 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package zerotermsquery | ||
|
||
// ZeroTermsQuery sets the "zero_terms_query" field in the matchType object. | ||
// | ||
// This method specifies the behavior of the match query when no terms remain after analysis, | ||
// such as when all terms are stop words. It updates the matchType object to include the provided | ||
// zeroTermsQuery value, which determines how the query should respond in this scenario. | ||
// | ||
// Example usage: | ||
// | ||
// match := es.Match("field", "value").ZeroTermsQuery(ZeroTermsQuery.All) | ||
// // match now has the "zero_terms_query" field set to "all" in the matchType object. | ||
// | ||
// Parameters: | ||
// - zeroTermsQuery: A ZeroTermsQuery value indicating the behavior for zero-term queries. | ||
// It can be either ZeroTermsQuery.All or ZeroTermsQuery.None. | ||
// | ||
// Returns: | ||
// | ||
// The updated matchType object with the "zero_terms_query" field set to the specified value. | ||
type ZeroTermsQuery string | ||
|
||
const ( | ||
// All indicates that all documents should be matched when no terms remain. | ||
All ZeroTermsQuery = "all" | ||
|
||
// None indicates that no documents should be matched when no terms remain. | ||
None ZeroTermsQuery = "none" | ||
) | ||
|
||
func (zeroTermsQuery ZeroTermsQuery) String() string { | ||
return string(zeroTermsQuery) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package zerotermsquery_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/Trendyol/es-query-builder/test/assert" | ||
|
||
ZeroTermsQuery "github.com/Trendyol/es-query-builder/es/enums/match/zero-terms-query" | ||
) | ||
|
||
func Test_ZeroTermsQueryString(t *testing.T) { | ||
tests := []struct { | ||
zeroTermsQuery ZeroTermsQuery.ZeroTermsQuery | ||
result string | ||
}{ | ||
{ZeroTermsQuery.All, "all"}, | ||
{ZeroTermsQuery.None, "none"}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.result, func(t *testing.T) { | ||
assert.Equal(t, test.result, test.zeroTermsQuery.String()) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.