Fix index presence detection to work in ccs-only setups (#28926) (#29206)

This commit is contained in:
Felix Stürmer 2019-01-23 23:54:50 +01:00 committed by GitHub
parent a740e6ec24
commit 80dfdf74d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View file

@ -104,6 +104,12 @@ export interface InfraDatabaseResponse {
export interface InfraDatabaseSearchResponse<Hit = {}, Aggregations = undefined>
extends InfraDatabaseResponse {
_shards: {
total: number;
successful: number;
skipped: number;
failed: number;
};
aggregations?: Aggregations;
hits: {
total: number;

View file

@ -43,7 +43,21 @@ export class InfraElasticsearchSourceStatusAdapter implements InfraSourceStatusA
}
public async hasIndices(request: InfraFrameworkRequest, indexNames: string) {
return (await this.getIndexNames(request, indexNames)).length > 0;
return await this.framework
.callWithRequest(request, 'search', {
index: indexNames,
size: 0,
terminate_after: 1,
})
.then(
response => response._shards.total > 0,
err => {
if (err.status === 404) {
return false;
}
throw err;
}
);
}
}