Skip to content

Commit

Permalink
Add healthcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
tiberiuichim committed Mar 6, 2023
1 parent b710a4f commit 1860323
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/config/global-search-base-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import query from './query';
import filters from './filters';
import download from './download';
import vocabs from './vocabulary';
import healthcheck from './healthcheck';

import objectProvidesWhitelist from './json/objectProvidesWhitelist.json';
import spatialWhitelist from './json/spatialWhitelist.json';
Expand All @@ -22,7 +23,8 @@ const globalSearchBaseConfig = {
runtime_mappings: build_runtime_mappings(clusters),
useSearchPhrases: false,
searchAsYouType: false,
landingPageURL: '/en/advanced-search',
landingPageURL: null,
healthcheck,
getActiveFilters: 'getGlobalSearchActiveFilters',

...vocabs,
Expand Down
1 change: 1 addition & 0 deletions src/config/global-search-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import cloneDeep from 'lodash.clonedeep';
import globalSearchBaseConfig from './global-search-base-config.js';

let globalSearchConfig = cloneDeep(globalSearchBaseConfig);
globalSearchConfig.landingPageURL = '/en/advanced-search';

globalSearchConfig.facets = globalSearchConfig.facets.filter(
(facet) => facet['field'] !== 'subject.keyword',
Expand Down
23 changes: 23 additions & 0 deletions src/config/healthcheck.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import runRequest from '@eeacms/search/lib/runRequest';
import buildRequest from '@eeacms/search/lib/search/query';

export default function healthcheck(appConfig) {
// is index ok?
// return index update date
// run default query, see number of results
// nlpservice provides answer based on extracted term
// number of documents with error in data raw, type of error

return new Promise((resolve, reject) => {
const body = buildRequest({ filters: [] }, appConfig);
runRequest(body, appConfig).then((resp) => {
let total;
try {
total = resp.body.hits.total.value;
resolve({ documentCount: total });
} catch {
reject({ total: -1 });
}
});
});
}

0 comments on commit 1860323

Please sign in to comment.