81 lines
1.6 KiB
Go
81 lines
1.6 KiB
Go
package esquery
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestMatch(t *testing.T) {
|
|
runMapTests(t, []mapTest{
|
|
{
|
|
"simple match",
|
|
Match("title", "sample text"),
|
|
map[string]interface{}{
|
|
"match": map[string]interface{}{
|
|
"title": map[string]interface{}{
|
|
"query": "sample text",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
"simple match",
|
|
Match("title", "sample text").Boost(50),
|
|
map[string]interface{}{
|
|
"match": map[string]interface{}{
|
|
"title": map[string]interface{}{
|
|
"query": "sample text",
|
|
"boost": 50,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
"match with more params",
|
|
Match("issue_number").Query(16).Transpositions(false).MaxExpansions(32).Operator(OperatorAnd),
|
|
map[string]interface{}{
|
|
"match": map[string]interface{}{
|
|
"issue_number": map[string]interface{}{
|
|
"query": 16,
|
|
"max_expansions": 32,
|
|
"transpositions": false,
|
|
"operator": "AND",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
"match_bool_prefix",
|
|
MatchBoolPrefix("title", "sample text"),
|
|
map[string]interface{}{
|
|
"match_bool_prefix": map[string]interface{}{
|
|
"title": map[string]interface{}{
|
|
"query": "sample text",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
"match_phrase",
|
|
MatchPhrase("title", "sample text"),
|
|
map[string]interface{}{
|
|
"match_phrase": map[string]interface{}{
|
|
"title": map[string]interface{}{
|
|
"query": "sample text",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
{
|
|
"match_phrase_prefix",
|
|
MatchPhrasePrefix("title", "sample text"),
|
|
map[string]interface{}{
|
|
"match_phrase_prefix": map[string]interface{}{
|
|
"title": map[string]interface{}{
|
|
"query": "sample text",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
}
|