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

Function TestQueryStringQueryIntegration

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

Source from the content-addressed store, hash-verified

47}
48
49func TestQueryStringQueryIntegration(t *testing.T) {
50 client := setupTestClientAndCreateIndexAndAddDocs(t) //, SetTraceLog(log.New(os.Stdout, "", log.LstdFlags)))
51
52 q := NewQueryStringQuery("Golang")
53
54 // Match all should return all documents
55 searchResult, err := client.Search().
56 Index(testIndexName).
57 Query(q).
58 Pretty(true).
59 Do(context.TODO())
60 if err != nil {
61 t.Fatal(err)
62 }
63 if searchResult.Hits == nil {
64 t.Errorf("expected SearchResult.Hits != nil; got nil")
65 }
66 if got, want := searchResult.TotalHits(), int64(1); got != want {
67 t.Errorf("expected SearchResult.TotalHits() = %d; got %d", want, got)
68 }
69 if got, want := len(searchResult.Hits.Hits), 1; got != want {
70 t.Errorf("expected len(SearchResult.Hits.Hits) = %d; got %d", want, got)
71 }
72}

Callers

nothing calls this directly

Calls 10

NewQueryStringQueryFunction · 0.85
SearchMethod · 0.80
FatalMethod · 0.80
ErrorfMethod · 0.80
TotalHitsMethod · 0.80
DoMethod · 0.65
PrettyMethod · 0.45
QueryMethod · 0.45
IndexMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…