Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions libbeat/outputs/elasticsearch/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"strconv"

"github.com/pkg/errors"

"github.com/elastic/beats/libbeat/common"
)

// QueryResult contains the result of a query.
Expand Down Expand Up @@ -235,6 +237,9 @@ func (es *Connection) SearchURIWithBody(
params map[string]string,
body interface{},
) (int, *SearchResults, error) {
if !es.version.LessThan(&common.Version{Major: 8}) {
docType = ""
}
status, resp, err := es.apiCall("GET", index, docType, "_search", "", params, body)
if err != nil {
return status, nil, err
Expand Down
4 changes: 2 additions & 2 deletions libbeat/outputs/elasticsearch/api_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func TestIndex(t *testing.T) {
}
_, result, err := client.SearchURIWithBody(index, "", nil, map[string]interface{}{})
if err != nil {
t.Errorf("SearchUriWithBody() returns an error: %s", err)
t.Fatalf("SearchUriWithBody() returns an error: %s", err)
}
if result.Hits.Total.Value != 1 {
t.Errorf("Wrong number of search results: %d", result.Hits.Total.Value)
Expand All @@ -72,7 +72,7 @@ func TestIndex(t *testing.T) {
}
_, result, err = client.SearchURI(index, "test", params)
if err != nil {
t.Errorf("SearchUri() returns an error: %s", err)
t.Fatalf("SearchUri() returns an error: %s", err)
}
if result.Hits.Total.Value != 1 {
t.Errorf("Wrong number of search results: %d", result.Hits.Total.Value)
Expand Down