-
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.
feature: add escape, type, fuzzy_rewrite, tie_breaker to queryStringQ…
…uery
- Loading branch information
1 parent
d56b187
commit d1581ac
Showing
16 changed files
with
368 additions
and
145 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
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,46 @@ | ||
package textquerytype | ||
|
||
// TextQueryType represents the type of text query to use in query string queries. | ||
// | ||
// TextQueryType is a string type that defines how the query text is analyzed and matched | ||
// against fields in the search index. It allows specifying various query strategies | ||
// based on the desired behavior. | ||
// | ||
// Constants: | ||
// - Bestfields: Use the best matching fields for scoring. | ||
// - Mostfields: Combine scores from all matching fields. | ||
// - Crossfields: Treat matching fields as a single field. | ||
// - Phrase: Match terms as a phrase. | ||
// - Phraseprefix: Match terms as a phrase with a prefix. | ||
// - Boolprefix: Use a boolean query with prefix matching. | ||
// | ||
// Example usage: | ||
// | ||
// var queryType TextQueryType = Bestfields | ||
// | ||
// // Use queryType in a query string configuration. | ||
type TextQueryType string | ||
|
||
const ( | ||
// Bestfields indicates that the best matching fields should be used for scoring. | ||
Bestfields TextQueryType = "best_fields" | ||
|
||
// Mostfields indicates that the scores from all matching fields should be combined. | ||
Mostfields TextQueryType = "most_fields" | ||
|
||
// Crossfields indicates that matching fields should be treated as a single field. | ||
Crossfields TextQueryType = "cross_fields" | ||
|
||
// Phrase indicates that terms should be matched as a phrase. | ||
Phrase TextQueryType = "phrase" | ||
|
||
// Phraseprefix indicates that terms should be matched as a phrase with a prefix. | ||
Phraseprefix TextQueryType = "phrase_prefix" | ||
|
||
// Boolprefix indicates that a boolean query with prefix matching should be used. | ||
Boolprefix TextQueryType = "bool_prefix" | ||
) | ||
|
||
func (textQueryType TextQueryType) String() string { | ||
return string(textQueryType) | ||
} |
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,29 @@ | ||
package textquerytype_test | ||
|
||
import ( | ||
"testing" | ||
|
||
TextQueryType "github.com/Trendyol/es-query-builder/es/enums/text-query-type" | ||
|
||
"github.com/Trendyol/es-query-builder/test/assert" | ||
) | ||
|
||
func Test_TextQueryTypeString(t *testing.T) { | ||
tests := []struct { | ||
textQueryType TextQueryType.TextQueryType | ||
result string | ||
}{ | ||
{TextQueryType.Bestfields, "best_fields"}, | ||
{TextQueryType.Mostfields, "most_fields"}, | ||
{TextQueryType.Crossfields, "cross_fields"}, | ||
{TextQueryType.Phrase, "phrase"}, | ||
{TextQueryType.Phraseprefix, "phrase_prefix"}, | ||
{TextQueryType.Boolprefix, "bool_prefix"}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.result, func(t *testing.T) { | ||
assert.Equal(t, test.result, test.textQueryType.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
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
Oops, something went wrong.