-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DOCS] Create documentation for fields.yml (#6049) #12505
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
[[event-fields-yml]] | ||
=== Defining field mappings | ||
|
||
Fields used by your Beat, along with their mapping details, must be defined in `_meta/fields.yml`. After editing this file, you must re-run `make update`. | ||
|
||
Define the field mappings in the `fields` array: | ||
|
||
[source,yaml] | ||
---------------------------------------------------------------------- | ||
- key: mybeat | ||
title: mybeat | ||
description: These are the fields used by mybeat. | ||
fields: | ||
- name: last_name <1> | ||
type: keyword <2> | ||
required: true <3> | ||
description: > <4> | ||
The last name. | ||
- name: first_name | ||
type: keyword | ||
required: true | ||
description: > | ||
The first name. | ||
- name: comment | ||
type: text | ||
required: false | ||
description: > | ||
Comment made by the user. | ||
---------------------------------------------------------------------- | ||
|
||
<1> `name`: The field name | ||
<2> `type`: The field type. The value for the `type` key can be any of the datatypes https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.html[available in Elasticsearch]. If no value is specified, the field will default to being a `keyword`. | ||
<3> `required`: Whether or not a field value is required | ||
<4> `description`: Some information about the field contents | ||
|
||
==== Mapping parameters | ||
Other mapping parameters can be specified for each field. Consult the https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-params.html[Elasticsearch reference] for more details on each of these parameters. | ||
|
||
[horizontal] | ||
`format`:: Specify a custom date format used by the field. | ||
`multi_fields`:: For `text` or `keyword` fields, `multi_fields` can be used to define multi-field mappings. | ||
`enabled`:: Whether or not the field is enabled. | ||
`analyzer`:: Which analyzer to use when indexing. | ||
`search_analyzer`:: Which analyzer to use when searching. | ||
`norms`:: Applies to `text` and `keyword` fields. Default is `false`. | ||
`dynamic`:: Dynamic field control. Can be one of `true` (default), `false` or `strict`. | ||
`index`:: Whether or not the field should be indexed. | ||
`doc_values`:: Whether or not the field should have doc values generated. See docs. | ||
`copy_to`:: Which field to copy the field value into. | ||
`ignore_above`:: When this property value is missing or is `0`, it receives the `libbeat` default value of `1024`. If the value is `-1`, the Elasticsearch default value will be applied. Any other specified value will be applied as-is. | ||
|
||
For example, we could use the `copy_to` mapping parameter to copy the `last_name` and `first_name` fields into the `full_name` field at index time: | ||
|
||
[source,yaml] | ||
---------------------------------------------------------------------- | ||
- key: mybeat | ||
title: mybeat | ||
description: These are the fields used by mybeat. | ||
fields: | ||
- name: last_name | ||
type: text | ||
required: true | ||
copy_to: full_name <1> | ||
description: > | ||
The last name. | ||
- name: first_name | ||
type: text | ||
required: true | ||
copy_to: full_name <2> | ||
description: > | ||
The first name. | ||
- name: full_name | ||
type: text | ||
required: false | ||
description: > | ||
The last_name and first_name combined into one field for easy searchability. | ||
---------------------------------------------------------------------- | ||
<1> Copy the value of `last_name` into `full_name` | ||
<2> Copy the value of `first_name` into `full_name` | ||
|
||
There are also some Kibana-specific properties, not detailed here. These are: `analyzed`, `count`, `searchable`, `aggregatable`, `script`. Kibana parameters can also be described using the `pattern`, `input_format`, `output_format`, `output_precision`, `label_template`, `url_template` and `open_link_in_current_tab`. | ||
|
||
==== Defining text multi-fields | ||
There are various options that can be applied when using text fields. A simple text field using the default analyzer can be defined without any other options, as in the example above. | ||
|
||
To keep the original keyword value when using `text` mappings, for instance to use in aggregations or ordering, a multi-field mapping can be used: | ||
|
||
[source,yaml] | ||
---------------------------------------------------------------------- | ||
- key: mybeat | ||
title: mybeat | ||
description: These are the fields used by mybeat. | ||
fields: | ||
- name: city | ||
type: text | ||
multi_fields: <1> | ||
- name: keyword <2> | ||
type: keyword <3> | ||
---------------------------------------------------------------------- | ||
<1> `multi_fields`: Define the `multi_fields` mapping parameter | ||
<2> `name`: This is a conventional name for a multi-field. It can be anything (`raw` is another common option) but the convention is to use `keyword`. | ||
<3> `type`: Specify the `keyword` type so we can use the field in aggregations or to order documents. | ||
|
||
Consult the https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-fields.html[reference] for more information on multi-fields. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both
surname
andforenames
here are themselveskeyword
types, which would make this redundant, right? The description above also describes using this on text fields, not keywords. Perhaps this section should use a different example field that would more naturally be of type text.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bestpath-gb Will you be able to update the example as suggested here? I appreciate the effort that you put into creating this PR and would like to help you get this merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback. Sorry for the delay in getting back to this. I'm hoping to review and update the examples this week.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was a great catch, @faec . I've updated the examples based on the Elasticsearch reference for those mapping parameters.