-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure that data is not lost when parsing EQL responses
The shared search utilities expect that response data exists in the response's body field. However, in an EQL response this information also exists as a sibling to the body field, and so we must normalize this data into the body before we can leverage these utilities with EQL queries.
- Loading branch information
Showing
3 changed files
with
37 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,8 @@ | |
*/ | ||
|
||
import { of, merge, timer, throwError } from 'rxjs'; | ||
import { takeWhile, switchMap, expand, mergeMap, tap } from 'rxjs/operators'; | ||
import { map, takeWhile, switchMap, expand, mergeMap, tap } from 'rxjs/operators'; | ||
import { ApiResponse } from '@elastic/elasticsearch'; | ||
|
||
import { | ||
AbortError, | ||
|
@@ -35,6 +36,15 @@ export const doPartialSearch = <SearchResponse = any>( | |
takeWhile((response) => !isCompleteResponse(response), true) | ||
); | ||
|
||
export const normalizeEqlResponse = <SearchResponse extends ApiResponse = ApiResponse>() => | ||
map<SearchResponse, SearchResponse>((eqlResponse) => ({ | ||
...eqlResponse, | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
rylnd
Author
Contributor
|
||
body: { | ||
...eqlResponse.body, | ||
...eqlResponse, | ||
}, | ||
})); | ||
|
||
export const throwOnEsError = () => | ||
mergeMap((r: IKibanaSearchResponse) => | ||
isErrorResponse(r) ? merge(of(r), throwError(new AbortError())) : of(r) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
So looks like the shape of the response had changed, but not necessarily it's contents? That's good. I was worried we wouldn't have access to that meta information any more.