Skip to content

Commit

Permalink
Fit runtime field on line (backport #71470) (#71600)
Browse files Browse the repository at this point in the history
This shrinks a runtime field definition so that it fits on the screen
without scrolling. It also converts the doc into a test so we can be
sure it continues to work.

Relates to #69291
  • Loading branch information
nik9000 authored Apr 13, 2021
1 parent 5ad0001 commit 9950afb
Showing 1 changed file with 41 additions and 4 deletions.
45 changes: 41 additions & 4 deletions docs/reference/search/search.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -452,15 +452,52 @@ script has access to the entire context of a document, including the original
Your script must include `emit` to return calculated values. For
example:
+
[source,js]
[source,js,indent=0]
----
"script": {
"source": "emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ROOT))"
}
include::search.asciidoc[tag=runtime-script]
----
// NOTCONSOLE
====

////
[source,console]
----
POST _search?size=1&filter_path=hits.hits
{
"runtime_mappings": {
"dow": {
"type": "keyword",
// tag::runtime-script[]
"script": "emit(doc['@timestamp'].value.dayOfWeekEnum.toString())"
// end::runtime-script[]
}
},
"fields": [{"field": "dow"}]
}
----
// TEST[setup:my_index]
[source,console-result]
----
{
"hits": {
"hits": [
{
"_index": $body.hits.hits.0._index,
"_type": "_doc",
"_id": $body.hits.hits.0._id,
"_score": $body.hits.hits.0._score,
"_source": $body.hits.hits.0._source,
"fields": {
"dow": ["SUNDAY"]
}
}
]
}
}
----
////

[[request-body-search-seq-no-primary-term]]
`seq_no_primary_term`::
(Optional, Boolean) If `true`, returns sequence number and primary term of the
Expand Down

0 comments on commit 9950afb

Please sign in to comment.