Skip to content

Commit

Permalink
[Entity Store] Aligning mappings with ECS (elastic#199001)
Browse files Browse the repository at this point in the history
## Summary

This PR corrects some of the mappings set in the component template to
follow ECS guidelines.

#### How to test

Initialise an entity engine via devtools:
```
POST kbn:/api/entity_store/engines/host/init
{}
```

Check the mappings with:
```
GET .entities.v1.latest.security_<entityType>_default/_mapping
```
  • Loading branch information
tiansivive authored and mbondyra committed Nov 8, 2024
1 parent 7f32199 commit 6bed2d8
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ describe('EntitiesList', () => {
fireEvent.click(columnHeader);
expect(mockUseEntitiesListQuery).toHaveBeenCalledWith(
expect.objectContaining({
sortField: 'entity.name.text',
sortField: 'entity.name',
sortOrder: 'asc',
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const useEntitiesListColumns = (): EntitiesListColumns => {
width: '5%',
},
{
field: 'entity.name.text',
field: 'entity.name',
name: (
<FormattedMessage
id="xpack.securitySolution.entityAnalytics.entityStore.entitiesList.nameColumn.title"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ export const BASE_ENTITY_INDEX_MAPPING: MappingProperties = {
type: 'keyword',
},
'entity.name': {
type: 'text',
type: 'keyword',
fields: {
text: {
type: 'keyword',
type: 'match_only_text',
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,17 @@ export const getHostUnitedDefinition: UnitedDefinitionBuilder = (fieldHistoryLen
collect({ field: 'host.domain' }),
collect({ field: 'host.hostname' }),
collect({ field: 'host.id' }),
collect({ field: 'host.os.name' }),
collect({
field: 'host.os.name',
mapping: {
type: 'keyword',
fields: {
text: {
type: 'match_only_text',
},
},
},
}),
collect({ field: 'host.os.type' }),
collect({
field: 'host.ip',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,17 @@ export const getUserUnitedDefinition: UnitedDefinitionBuilder = (fieldHistoryLen
fields: [
collect({ field: 'user.domain' }),
collect({ field: 'user.email' }),
collect({ field: 'user.full_name' }),
collect({
field: 'user.full_name',
mapping: {
type: 'keyword',
fields: {
text: {
type: 'match_only_text',
},
},
},
}),
collect({ field: 'user.hash' }),
collect({ field: 'user.id' }),
collect({ field: 'user.roles' }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ describe('getUnitedEntityDefinition', () => {
"entity.name": Object {
"fields": Object {
"text": Object {
"type": "keyword",
"type": "match_only_text",
},
},
"type": "text",
"type": "keyword",
},
"entity.source": Object {
"type": "keyword",
Expand All @@ -59,9 +59,19 @@ describe('getUnitedEntityDefinition', () => {
"type": "keyword",
},
"host.name": Object {
"fields": Object {
"text": Object {
"type": "match_only_text",
},
},
"type": "keyword",
},
"host.os.name": Object {
"fields": Object {
"text": Object {
"type": "match_only_text",
},
},
"type": "keyword",
},
"host.os.type": Object {
Expand Down Expand Up @@ -335,10 +345,10 @@ describe('getUnitedEntityDefinition', () => {
"entity.name": Object {
"fields": Object {
"text": Object {
"type": "keyword",
"type": "match_only_text",
},
},
"type": "text",
"type": "keyword",
},
"entity.source": Object {
"type": "keyword",
Expand All @@ -350,6 +360,11 @@ describe('getUnitedEntityDefinition', () => {
"type": "keyword",
},
"user.full_name": Object {
"fields": Object {
"text": Object {
"type": "match_only_text",
},
},
"type": "keyword",
},
"user.hash": Object {
Expand All @@ -359,6 +374,11 @@ describe('getUnitedEntityDefinition', () => {
"type": "keyword",
},
"user.name": Object {
"fields": Object {
"text": Object {
"type": "match_only_text",
},
},
"type": "keyword",
},
"user.risk.calculated_level": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ export class UnitedEntityDefinition {
...BASE_ENTITY_INDEX_MAPPING,
[identityField]: {
type: 'keyword',
fields: {
text: {
type: 'match_only_text',
},
},
},
};

Expand All @@ -107,6 +112,11 @@ export class UnitedEntityDefinition {

properties[identityField] = {
type: 'keyword',
fields: {
text: {
type: 'match_only_text',
},
},
};

return {
Expand Down

0 comments on commit 6bed2d8

Please sign in to comment.