Skip to content

Commit 38c6728

Browse files
committed
Update pattern_text documentation with new index sort setting
1 parent 9e08be5 commit 38c6728

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

docs/reference/elasticsearch/mapping-reference/pattern-text.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,16 @@ In both cases, all queries return a constant score of 1.0.
4343

4444
## Index sorting for improved compression
4545
The compression provided by `pattern_text` can be significantly improved if the index is sorted by the `template_id` field.
46-
For example, a typical approach would be to sort first by `message.template_id`, then by `@timestamp`, as shown in the following example.
46+
This sorting is not applied by default, but can be enabled for the `message` field of logs-mode indices (assuming it is of type `pattern_text`) by setting the index setting `index.logsdb.default_sort_on_message_template` to `true`.
47+
This will cause the index to be sorted by `hostname` (if present), then `message.template_id`, and finally by `@timestamp`.
48+
If the index is not logs-mode or the `pattern_text` field is named something other than `message`, index sorting can still be manually applied as shown in the following example.
4749

4850
```console
4951
PUT logs
5052
{
5153
"settings": {
5254
"index": {
53-
"sort.field": [ "message.template_id", "@timestamp" ],
55+
"sort.field": [ "notice.template_id", "@timestamp" ],
5456
"sort.order": [ "asc", "desc" ]
5557
}
5658
},
@@ -59,7 +61,7 @@ PUT logs
5961
"@timestamp": {
6062
"type": "date"
6163
},
62-
"message": {
64+
"notice": {
6365
"type": "pattern_text"
6466
}
6567
}

0 commit comments

Comments
 (0)