ElasticSearch engine throw MissingIndexError if error type is index_not_found_exception

Signed-off-by: Emma Indal <emma.indahl@gmail.com>
This commit is contained in:
Emma Indal
2022-06-20 15:48:44 +02:00
parent 18dad948a1
commit c30ecd900f
@@ -26,6 +26,7 @@ import {
SearchEngine,
SearchQuery,
} from '@backstage/plugin-search-common';
import { MissingIndexError } from '@backstage/plugin-search-backend-node';
import { Client } from '@elastic/elasticsearch';
import esb from 'elastic-builder';
import { isEmpty, isNaN as nan, isNumber } from 'lodash';
@@ -362,6 +363,9 @@ export class ElasticSearchSearchEngine implements SearchEngine {
previousPageCursor,
};
} catch (e) {
if (e.meta.body.error.type === 'index_not_found_exception') {
throw new MissingIndexError(`Missing index for ${queryIndices}`, e);
}
this.logger.error(
`Failed to query documents for indices ${queryIndices}`,
e,