Added timeout support in bulk and msearch helpers (#1206)

This commit is contained in:
Tomas Della Vedova
2020-06-03 10:33:08 +02:00
committed by GitHub
parent dbbee273d9
commit 80817a00f9
7 changed files with 367 additions and 29 deletions

View File

@ -27,6 +27,7 @@ const b = client.helpers.bulk<Record<string, any>>({
return { index: { _index: 'test' } }
},
flushBytes: 5000000,
flushInterval: 30000,
concurrency: 5,
retries: 3,
wait: 5000,
@ -58,7 +59,7 @@ expectError(
const options = {
datasource: [],
onDocument (doc: Record<string, any>) {
return { index: { _index: 'test' } }
return { index: { _index: 'test' } }
}
}
expectAssignable<BulkHelperOptions<Record<string, any>>>(options)
@ -139,20 +140,20 @@ expectError(
}
// with type defs
{
{
interface ShardsResponse {
total: number;
successful: number;
failed: number;
skipped: number;
}
interface Explanation {
value: number;
description: string;
details: Explanation[];
}
interface SearchResponse<T> {
took: number;
timed_out: boolean;
@ -178,7 +179,7 @@ expectError(
};
aggregations?: any;
}
interface Source {
foo: string
}
@ -208,20 +209,20 @@ expectError(
match: { foo: string }
}
}
interface ShardsResponse {
total: number;
successful: number;
failed: number;
skipped: number;
}
interface Explanation {
value: number;
description: string;
details: Explanation[];
}
interface SearchResponse<T> {
took: number;
timed_out: boolean;
@ -247,7 +248,7 @@ expectError(
};
aggregations?: any;
}
interface Source {
foo: string
}
@ -310,7 +311,7 @@ expectError(
}
// with type defs
{
{
interface Source {
foo: string
}
@ -337,7 +338,7 @@ expectError(
match: { foo: string }
}
}
interface Source {
foo: string
}
@ -415,7 +416,7 @@ expectError(
match: { foo: string }
}
}
interface Source {
foo: string
}
@ -436,7 +437,8 @@ expectError(
/// .helpers.msearch
const s = client.helpers.msearch({
operations: 20,
operations: 5,
flushInterval: 500,
concurrency: 5,
retries: 5,
wait: 5000
@ -456,4 +458,4 @@ expectType<void>(s.search({ index: 'foo'}, { query: {} }, (err, result) => {
expectType<void>(s.search<string, Record<string, any>, string>({ index: 'foo'}, { query: {} }, (err, result) => {
expectType<ApiError>(err)
expectType<ApiResponse<string, string>>(result)
}))
}))