From 3a2e4de6eb3f4d802572dfa5311f75f2682b74a7 Mon Sep 17 00:00:00 2001 From: Oliver Eilhard Date: Fri, 17 Dec 2021 10:18:25 +0100 Subject: [PATCH] Add another test for TermQuery --- search_queries_term_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/search_queries_term_test.go b/search_queries_term_test.go index 8def1df4..61ada8a0 100644 --- a/search_queries_term_test.go +++ b/search_queries_term_test.go @@ -26,6 +26,23 @@ func TestTermQuery(t *testing.T) { } } +func TestTermQueryWithCaseInsensitive(t *testing.T) { + q := NewTermQuery("user", "ki").CaseInsensitive(true) + src, err := q.Source() + if err != nil { + t.Fatal(err) + } + data, err := json.Marshal(src) + if err != nil { + t.Fatalf("marshaling to JSON failed: %v", err) + } + got := string(data) + expected := `{"term":{"user":{"case_insensitive":true,"value":"ki"}}}` + if got != expected { + t.Errorf("expected\n%s\n,got:\n%s", expected, got) + } +} + func TestTermQueryWithOptions(t *testing.T) { q := NewTermQuery("user", "ki") q = q.Boost(2.79)