MCPcopy Create free account
hub / github.com/olivere/elastic / TestQueryStringQuery

Function TestQueryStringQuery

search_queries_query_string_test.go:13–29  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestQueryStringQuery(t *testing.T) {
14 q := NewQueryStringQuery(`this AND that OR thus`)
15 q = q.DefaultField("content")
16 src, err := q.Source()
17 if err != nil {
18 t.Fatal(err)
19 }
20 data, err := json.Marshal(src)
21 if err != nil {
22 t.Fatalf("marshaling to JSON failed: %v", err)
23 }
24 got := string(data)
25 expected := `{"query_string":{"default_field":"content","query":"this AND that OR thus"}}`
26 if got != expected {
27 t.Errorf("expected\n%s\n,got:\n%s", expected, got)
28 }
29}
30
31func TestQueryStringQueryTimeZone(t *testing.T) {
32 q := NewQueryStringQuery(`tweet_date:[2015-01-01 TO 2017-12-31]`)

Callers

nothing calls this directly

Calls 6

DefaultFieldMethod · 0.95
SourceMethod · 0.95
NewQueryStringQueryFunction · 0.85
FatalMethod · 0.80
FatalfMethod · 0.80
ErrorfMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…