Skip to content

Commit

Permalink
Add alnum (text pattern) multi field to host.name and observer.name
Browse files Browse the repository at this point in the history
The background is to make parts of the FQDN or hostname searchable.
Example:

```
POST _analyze
{
  "analyzer": "pattern",
  "text": "host55-bmc.example.net"
}
```

Output:

```json
{
  "tokens" : [
    {
      "token" : "host55",
      "start_offset" : 0,
      "end_offset" : 6,
      "type" : "word",
      "position" : 0
    },
    {
      "token" : "bmc",
      "start_offset" : 7,
      "end_offset" : 10,
      "type" : "word",
      "position" : 1
    },
    {
      "token" : "example",
      "start_offset" : 11,
      "end_offset" : 18,
      "type" : "word",
      "position" : 2
    },
    {
      "token" : "net",
      "start_offset" : 19,
      "end_offset" : 22,
      "type" : "word",
      "position" : 3
    }
  ]
}
```
  • Loading branch information
ypid-geberit committed Sep 2, 2021
1 parent 8558a6c commit 5034873
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions schemas/host.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
level: core
type: keyword
short: Name of the host.
multi_fields:
- type: text
name: alnum
analyzer: pattern
description: >
Name of the host.
Expand Down
4 changes: 4 additions & 0 deletions schemas/observer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
level: extended
type: keyword
short: Custom name of the observer.
multi_fields:
- type: text
name: alnum
analyzer: pattern
description: >
Custom name of the observer.
Expand Down
2 changes: 1 addition & 1 deletion scripts/generators/es_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def entry_for(field):
if mf_type == 'keyword':
ecs_helpers.dict_copy_existing_keys(mf, mf_entry, ['normalizer', 'ignore_above'])
elif mf_type == 'text':
ecs_helpers.dict_copy_existing_keys(mf, mf_entry, ['norms'])
ecs_helpers.dict_copy_existing_keys(mf, mf_entry, ['norms', 'analyzer'])
field_entry['fields'][mf['name']] = mf_entry

except KeyError as ex:
Expand Down

0 comments on commit 5034873

Please sign in to comment.