forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
345 changed files
with
11,417 additions
and
2,782 deletions.
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
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,136 @@ | ||
--- | ||
id: enElasticsearchPainlessPainlessFieldContext | ||
slug: /en/elasticsearch/painless/painless-field-context | ||
title: Field context | ||
description: Description to be written | ||
tags: [] | ||
--- | ||
|
||
<div id="painless-field-context"></div> | ||
|
||
Use a Painless script to create a | ||
[script field](((ref))/search-fields.html#script-fields) to return | ||
a customized value for each document in the results of a query. | ||
|
||
**Variables** | ||
|
||
`params` (`Map`, read-only) | ||
: User-defined parameters passed in as part of the query. | ||
|
||
`doc` (`Map`, read-only) | ||
: Contains the fields of the specified document where each field is a | ||
`List` of values. | ||
|
||
[`params['_source']`](((ref))/mapping-source-field.html) (`Map`, read-only) | ||
: Contains extracted JSON in a `Map` and `List` structure for the fields | ||
existing in a stored document. | ||
|
||
**Return** | ||
|
||
`Object` | ||
: The customized value for each document. | ||
|
||
**API** | ||
|
||
Both the standard <DocLink id="enElasticsearchPainlessPainlessApiReferenceShared">Painless API</DocLink> and | ||
<DocLink id="enElasticsearchPainlessPainlessApiReferenceField">Specialized Field API</DocLink> are available. | ||
|
||
**Example** | ||
|
||
To run this example, first follow the steps in | ||
<DocLink id="enElasticsearchPainlessPainlessContextExamples">context examples</DocLink>. | ||
|
||
You can then use these two example scripts to compute custom information | ||
for each search hit and output it to two new fields. | ||
|
||
The first script gets the doc value for the `datetime` field and calls | ||
the `getDayOfWeekEnum` function to determine the corresponding day of the week. | ||
|
||
```Painless | ||
doc['datetime'].value.getDayOfWeekEnum().getDisplayName(TextStyle.FULL, Locale.ROOT) | ||
``` | ||
|
||
The second script calculates the number of actors. Actors' names are stored | ||
as a keyword array in the `actors` field. | ||
|
||
```Painless | ||
doc['actors'].size() [^1] | ||
``` | ||
[^1]: By default, doc values are not available for `text` fields. If `actors` was | ||
a `text` field, you could still calculate the number of actors by extracting | ||
values from `_source` with `params['_source']['actors'].size()`. | ||
|
||
The following request returns the calculated day of week and the number of | ||
actors that appear in each play: | ||
|
||
```console | ||
GET seats/_search | ||
{ | ||
"size": 2, | ||
"query": { | ||
"match_all": {} | ||
}, | ||
"script_fields": { | ||
"day-of-week": { | ||
"script": { | ||
"source": "doc['datetime'].value.getDayOfWeekEnum().getDisplayName(TextStyle.FULL, Locale.ROOT)" | ||
} | ||
}, | ||
"number-of-actors": { | ||
"script": { | ||
"source": "doc['actors'].size()" | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
{/* TEST[setup:seats] */} | ||
|
||
```console-result | ||
{ | ||
"took" : 68, | ||
"timed_out" : false, | ||
"_shards" : { | ||
"total" : 1, | ||
"successful" : 1, | ||
"skipped" : 0, | ||
"failed" : 0 | ||
}, | ||
"hits" : { | ||
"total" : { | ||
"value" : 11, | ||
"relation" : "eq" | ||
}, | ||
"max_score" : 1.0, | ||
"hits" : [ | ||
{ | ||
"_index" : "seats", | ||
"_id" : "1", | ||
"_score" : 1.0, | ||
"fields" : { | ||
"day-of-week" : [ | ||
"Thursday" | ||
], | ||
"number-of-actors" : [ | ||
4 | ||
] | ||
} | ||
}, | ||
{ | ||
"_index" : "seats", | ||
"_id" : "2", | ||
"_score" : 1.0, | ||
"fields" : { | ||
"day-of-week" : [ | ||
"Thursday" | ||
], | ||
"number-of-actors" : [ | ||
1 | ||
] | ||
} | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
{/* TESTRESPONSE[s/"took" : 68/"took" : "$body.took"/] */} |
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,5 @@ | ||
pr: 105393 | ||
summary: Adding support for hex-encoded byte vectors on knn-search | ||
area: Vector Search | ||
type: feature | ||
issues: [] |
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,6 @@ | ||
pr: 105442 | ||
summary: Handling exceptions on watcher reload | ||
area: Watcher | ||
type: bug | ||
issues: | ||
- 69842 |
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,5 @@ | ||
pr: 105470 | ||
summary: Add retrievers using the parser-only approach | ||
area: Ranking | ||
type: enhancement | ||
issues: [] |
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,5 @@ | ||
pr: 105894 | ||
summary: Add allocation stats | ||
area: Allocation | ||
type: enhancement | ||
issues: [] |
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,5 @@ | ||
pr: 105941 | ||
summary: Field caps performance pt2 | ||
area: Search | ||
type: enhancement | ||
issues: [] |
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,5 @@ | ||
pr: 106094 | ||
summary: "ESQL: Support partially folding CASE" | ||
area: ES|QL | ||
type: enhancement | ||
issues: [] |
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,5 @@ | ||
pr: 106150 | ||
summary: Use correct system index bulk executor | ||
area: CRUD | ||
type: bug | ||
issues: [] |
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,6 @@ | ||
pr: 106171 | ||
summary: Do not log error on node restart when the transform is already failed | ||
area: Transform | ||
type: enhancement | ||
issues: | ||
- 106168 |
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,5 @@ | ||
pr: 106172 | ||
summary: "[Profiling] Allow to override index settings" | ||
area: Application | ||
type: enhancement | ||
issues: [] |
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,6 @@ | ||
pr: 106189 | ||
summary: Fix numeric sorts in `_cat/nodes` | ||
area: CAT APIs | ||
type: bug | ||
issues: | ||
- 48070 |
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,5 @@ | ||
pr: 106247 | ||
summary: Fix a downsample persistent task assignment bug | ||
area: Downsampling | ||
type: bug | ||
issues: [] |
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,5 @@ | ||
pr: 97561 | ||
summary: Add index forecasts to /_cat/allocation output | ||
area: Allocation | ||
type: enhancement | ||
issues: [] |
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,6 @@ | ||
pr: 99048 | ||
summary: String sha512() painless function | ||
area: Infra/Scripting | ||
type: enhancement | ||
issues: | ||
- 97691 |
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
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
Oops, something went wrong.