Yes it does... it is quite powerfull...
It came out as Tech Preview in 8.10
8.14 is GA
So that depends on your mapping show this and we can see
GET your-index/_mapping/field/message
Depending on that you may end up using ...
.extract(params._source.message))
<< if you do not have a keyword subfield
or
.extract(doc[\"message.keyword\"].value))"
<< if you have a .keyword subfield
See Here
In most cases, retrieve field values through doc_values
whenever possible. Accessing doc_values
with a runtime field is faster than retrieving values from _source
because of how data is loaded from Lucene.
However, there are cases where retrieving fields from _source
is necessary. For example, text
fields do not have doc_values
available by default, so you have to retrieve values from _source
. In other instances, you might choose to disable doc_values
on a specific field.
You can alternatively prefix the field you want to retrieve values for with params._source
(such as params._source.day_of_week
). For simplicity, defining a runtime field in the mapping definition without a script is the recommended option, whenever possible.
No they are created at the data view or mapping level
Example here is pretty close... I just have not got the last "
s right
PUT discuss-test/_mappings
{
"runtime": {
"http": {
"type": "composite",
"script": "emit(grok(\"\\\\[%{DATA:timestamp}\\\\] %{DATA:host} %{DATA:verb} %{DATA:url} %{DATA:http_version} %{DATA:response_code} %{DATA:bytes} %{DATA:response_time} %{GREEDYDATA:message_details}\").extract(params._source.message))",
"fields": {
"url": {
"type": "keyword"
},
"verb": {
"type": "keyword"
},
"response_code": {
"type": "keyword"
}
}
}
}
}
POST discuss-test/_doc
{
"@timestamp": "2024-07-07T19:01:42.736Z",
"message" : """[Jul 7, 2024 @ 12:01:41] abcdef "POST /app/rest/xyz?somethingselase HTTP/1.1" 500 676866 200ms idontknow tailed_path: /path"""
}
GET discuss-test/_search
{
"_source": ["*"],
"fields": [
"*"
]
}
# Results just need to get the last quotes
#! Elasticsearch built-in security features are not enabled. Without authentication, your cluster could be accessible to anyone. See https://www.elastic.co/guide/en/elasticsearch/reference/7.17/security-minimal-setup.html to enable security.
{
"took" : 1,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 1,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "discuss-test",
"_type" : "_doc",
"_id" : "az8Wj5ABfwsjeNV6XlhS",
"_score" : 1.0,
"_source" : {
"@timestamp" : "2024-07-07T19:01:42.736Z",
"message" : """[Jul 7, 2024 @ 12:01:41] abcdef "POST /app/rest/xyz?somethingselase HTTP/1.1" 500 676866 200ms idontknow tailed_path: /path"""
},
"fields" : {
"http.response_code" : [
"500"
],
"@timestamp" : [
"2024-07-07T19:01:42.736Z"
],
"http.verb" : [
"\"POST"
],
"message.keyword" : [
"""[Jul 7, 2024 @ 12:01:41] abcdef "POST /app/rest/xyz?somethingselase HTTP/1.1" 500 676866 200ms idontknow tailed_path: /path"""
],
"http.url" : [
"/app/rest/xyz?somethingselase"
],
"message" : [
"""[Jul 7, 2024 @ 12:01:41] abcdef "POST /app/rest/xyz?somethingselase HTTP/1.1" 500 676866 200ms idontknow tailed_path: /path"""
]
}
}
]
}
}