Skip to content

Commit

Permalink
[7.x] Watcher - ensure that rest_total_hits_as_int is persisted (#65988
Browse files Browse the repository at this point in the history
…) (#66029)

A minor logic bug only persists the rest_total_hits_as_int
option for Watch search inputs if the value is true.
  • Loading branch information
jakelandis authored Dec 8, 2020
1 parent 7244948 commit 4c9b9b8
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,42 @@ setup:

- match: { _source.key: "value" }

---
"Test persist rest_total_hits_as_int":
- do:
watcher.put_watch:
id: "my_watch1"
body: >
{
"trigger": {
"schedule" : { "cron" : "0 0 0 1 * ? 2099" }
},
"input": {
"search" : {
"request" : {
"indices" : [ "my_test_index" ],
"rest_total_hits_as_int": false,
"body" : {
"query": {
"match_all" : {}
}
}
}
}
},
"actions": {
"test_index": {
"index": {
"index": "test"
}
}
}
}
- match: { _id: "my_watch1" }

- do:
watcher.get_watch:
id: "my_watch1"
- match: { found : true}
- match: { _id: "my_watch1" }
- match: { watch.input.search.request.rest_total_hits_as_int: false }
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
if (types != null) {
builder.array(TYPES_FIELD.getPreferredName(), types);
}
if (restTotalHitsAsInt) {
builder.field(REST_TOTAL_HITS_AS_INT_FIELD.getPreferredName(), restTotalHitsAsInt);
}

builder.field(REST_TOTAL_HITS_AS_INT_FIELD.getPreferredName(), restTotalHitsAsInt);

if (searchSource != null && searchSource.length() > 0) {
try (InputStream stream = searchSource.streamInput()) {
builder.rawField(BODY_FIELD.getPreferredName(), stream);
Expand Down

0 comments on commit 4c9b9b8

Please sign in to comment.