Skip to content

Commit e06f90f

Browse files
committed
Added 'result' field to Elasticsearch QueryResult
Added 'result' field to Elasticsearch QueryResult struct for compatibility with 6.x Index and Delete API responses. See elastic/elasticsearch#25516 for more info. Fixes elastic#4661
1 parent 573eb67 commit e06f90f

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

CHANGELOG.asciidoc

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ https://github.com/elastic/beats/compare/v6.0.0-alpha2...master[Check the HEAD d
7474
- Add `test output` command, to test Elasticsearch and Logstash output settings. {pull}4590[4590]
7575
- Introduce configurable event queue settings: queue.mem.events, queue.mem.flush.min_events and queue.mem.flush.timeout. {pull}4650[4650]
7676
- Enable pipelining in Logstash output by default. {pull}4650[4650]
77+
- Added 'result' field to Elasticsearch QueryResult struct for compatibility with 6.x Index and Delete API responses. {issue]4661[4661]
7778

7879
*Filebeat*
7980

libbeat/outputs/elasticsearch/api.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ type QueryResult struct {
1414
ID string `json:"_id"`
1515
Source json.RawMessage `json:"_source"`
1616
Version int `json:"_version"`
17-
Found bool `json:"found"`
1817
Exists bool `json:"exists"`
19-
Created bool `json:"created"`
18+
Found bool `json:"found"` // Only used prior to ES 6. You must also check for Result == "found".
19+
Created bool `json:"created"` // Only used prior to ES 6. You must also check for Result == "created".
20+
Result string `json:"result"` // Only used in ES 6+.
2021
Acknowledged bool `json:"acknowledged"`
2122
Matches []string `json:"matches"`
2223
}

libbeat/outputs/elasticsearch/api_integration_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ func TestIndex(t *testing.T) {
3636
if err != nil {
3737
t.Fatalf("Index() returns error: %s", err)
3838
}
39-
if !resp.Created {
40-
t.Errorf("Index() fails: %s", resp)
39+
if !resp.Created && resp.Result != "created" {
40+
t.Fatalf("Index() fails: %s", resp)
4141
}
4242

4343
params = map[string]string{
@@ -103,7 +103,7 @@ func TestIngest(t *testing.T) {
103103
if err != nil {
104104
t.Fatalf("Ingest() returns error: %s", err)
105105
}
106-
if !resp.Created {
106+
if !resp.Created && resp.Result != "created" {
107107
t.Errorf("Ingest() fails: %s", resp)
108108
}
109109

0 commit comments

Comments
 (0)