diff --git a/opencti-platform/opencti-graphql/src/database/elasticSearch.js b/opencti-platform/opencti-graphql/src/database/elasticSearch.js index 01a04cad8f09..f7e0a23122d6 100644 --- a/opencti-platform/opencti-graphql/src/database/elasticSearch.js +++ b/opencti-platform/opencti-graphql/src/database/elasticSearch.js @@ -453,7 +453,7 @@ export const elCount = (user, indexName, options = {}) => { path: 'connections', query: { bool: { - must: [{ match_phrase: { [`connections.internal_id`]: fromId } }], + must: [{ match_phrase: { [`connections.internal_id.keyword`]: fromId } }], }, }, }, @@ -466,7 +466,7 @@ export const elCount = (user, indexName, options = {}) => { const filters = []; for (let index = 0; index < toTypes.length; index += 1) { filters.push({ - match_phrase: { 'connections.types': toTypes[index] }, + match_phrase: { 'connections.types.keyword': toTypes[index] }, }); } must = R.append( @@ -603,7 +603,7 @@ export const elFindByFromAndTo = async (user, fromId, toId, relationshipType) => path: 'connections', query: { bool: { - must: [{ match_phrase: { 'connections.internal_id': fromId } }], + must: [{ match_phrase: { 'connections.internal_id.keyword': fromId } }], }, }, }, @@ -613,7 +613,7 @@ export const elFindByFromAndTo = async (user, fromId, toId, relationshipType) => path: 'connections', query: { bool: { - must: [{ match_phrase: { 'connections.internal_id': toId } }], + must: [{ match_phrase: { 'connections.internal_id.keyword': toId } }], }, }, }, @@ -954,7 +954,7 @@ export const elHistogramCount = async (user, type, field, interval, start, end, const typesFilters = []; for (let index = 0; index < toTypes.length; index += 1) { typesFilters.push({ - match_phrase: { 'connections.types': toTypes[index] }, + match_phrase: { 'connections.types.keyword': toTypes[index] }, }); } if (typesFilters.length > 0) { @@ -1038,7 +1038,10 @@ export const elPaginate = async (user, indexName, options = {}) => { if (types !== null && types.length > 0) { const should = R.flatten( types.map((typeValue) => { - return [{ match_phrase: { entity_type: typeValue } }, { match_phrase: { parent_types: typeValue } }]; + return [ + { match_phrase: { 'entity_type.keyword': typeValue } }, + { match_phrase: { 'parent_types.keyword': typeValue } }, + ]; }) ); must = R.append({ bool: { should, minimum_should_match: 1 } }, must); @@ -1704,7 +1707,7 @@ export const elUpdateAttributeValue = (key, previousValue, value) => { } index++; }`; - const query = { match_phrase: { [key]: previousValue } }; + const query = { match_phrase: { [`${key}.keyword`]: previousValue } }; return el .updateByQuery({ index: READ_DATA_INDICES, @@ -1777,7 +1780,7 @@ export const elUpdateConnectionsOfElement = (documentId, documentBody) => { path: 'connections', query: { bool: { - must: [{ match_phrase: { [`connections.internal_id`]: documentId } }], + must: [{ match_phrase: { [`connections.internal_id.keyword`]: documentId } }], }, }, },