Skip to content

Commit

Permalink
[backend] Fix testing with no field in relation aggregation
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelHassine committed Sep 21, 2023
1 parent 114fc9b commit fba17db
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions opencti-platform/opencti-graphql/src/database/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -1657,7 +1657,7 @@ export const elAggregationRelationsCount = async (context, user, indexName, opti
const body = await elQueryBodyBuilder(context, user, { ...searchOptions, noSize: true, noSort: true });
const aggregationFilters = await buildAggregationRelationFilters(context, user, aggregationOptions);
body.size = 0;
if (field === 'internal_id' || field === 'entity_type') {
if (field === 'internal_id' || field === 'entity_type' || field === null) {
body.aggs = {
connections: {
nested: {
Expand Down Expand Up @@ -1711,10 +1711,10 @@ export const elAggregationRelationsCount = async (context, user, indexName, opti
}
const query = { index: indexName, ignore_throttled: ES_IGNORE_THROTTLED, body };
logApp.debug('[SEARCH] aggregationRelationsCount', { query });
const isIdFields = field.endsWith('internal_id');
const isIdFields = field?.endsWith('internal_id');
return elRawSearch(context, user, types, query)
.then(async (data) => {
if (field === 'internal_id' || field === 'entity_type') {
if (field === 'internal_id' || field === 'entity_type' || field === null) {
const { buckets } = data.aggregations.connections.filtered.genres;
if (field === 'internal_id') {
return buckets.map((b) => ({ label: b.key, value: b.parent.weight.value }));
Expand Down

0 comments on commit fba17db

Please sign in to comment.