Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.14] Fix join keys ordering in a sequence (#76699) #76912

Merged
merged 1 commit into from
Aug 25, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,42 @@ setup:
user: SYSTEM
id: 123
valid: true
- index:
_index: eql_test
_id: 4
- event:
- category: network
"@timestamp": 2020-02-06T12:34:56Z
user: ADMIN
id: 123
valid: true
- index:
_index: eql_test
_id: 5
- event:
- category: network
"@timestamp": 2020-02-07T12:34:56Z
user: SYSTEM
id: 123
valid: true
- index:
_index: eql_test
_id: 6
- event:
- category: network
"@timestamp": 2020-02-08T12:34:56Z
user: ADMIN
id: 123
valid: true
- index:
_index: eql_test
_id: 7
- event:
- category: network
"@timestamp": 2020-02-09T12:34:56Z
user: SYSTEM
id: 123
valid: true

---
# Testing round-trip and the basic shape of the response
Expand Down Expand Up @@ -382,3 +418,13 @@ setup:
catch: missing
eql.get_status:
id: $id
---
"Sequence checking correct join key ordering.":

- do:
eql.search:
index: eql_test
body:
query: 'sequence by user [network where valid == true] [network where true]'
- match: {hits.sequences.0.join_keys.0: "ADMIN"}
- match: {hits.sequences.1.join_keys.0: "SYSTEM"}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.elasticsearch.xpack.eql.util.ReversedIterator;
import org.elasticsearch.xpack.ql.util.ActionListeners;

import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
Expand Down Expand Up @@ -548,6 +549,9 @@ private void payload(ActionListener<Payload> listener) {

// get results through search (to keep using PIT)
client.fetchHits(hits(completed), ActionListeners.map(listener, listOfHits -> {
if (criteria.get(0).descending()) {
Collections.reverse(completed);
}
SequencePayload payload = new SequencePayload(completed, listOfHits, false, timeTook());
close(listener);
return payload;
Expand Down