You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/asciidoc/reference/elasticsearch-misc-scripted-and-runtime-fields.adoc
+8-8
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,9 @@ Please refer to the Elasticsearch documentation about scripting (https://www.ela
6
6
In the context of Spring Data Elasticsearch you can use
7
7
8
8
* scripted fields that are used to return fields that are calculated on the result documents and added to the returned document.
9
-
* runtime fields that are calculated on the stored documents and can be used in a query and/or be returned in the search result.
9
+
* runtime fields that are calculated on the stored documents and can be used in a query and/or be returned in the search result.
10
10
11
-
The following code snippets will show what you can do (this show imperative code, but the reactive implementation works similar).
11
+
The following code snippets will show what you can do (these show imperative code, but the reactive implementation works similar).
12
12
13
13
== The person entity
14
14
@@ -62,7 +62,7 @@ public record Person(
62
62
----
63
63
64
64
<.> the `age` property will be calculated and filled in search results.
65
-
<.> a convenience constructor to set up the test data
65
+
<.> a convenience constructor to set up the test data.
66
66
====
67
67
68
68
Note that the `age` property is annotated with `@ScriptedField`.
@@ -87,7 +87,7 @@ public interface PersonRepository extends ElasticsearchRepository<Person, String
87
87
88
88
== The service class
89
89
90
-
The service class has a repository injected and an `ElasticsearchOperations` instance to show several ways of poplauting and using the `age` property.
90
+
The service class has a repository injected and an `ElasticsearchOperations` instance to show several ways of populating and using the `age` property.
91
91
We show the code split up in different pieces to put the explanations in
92
92
93
93
====
@@ -137,8 +137,8 @@ public class PersonService {
137
137
138
138
=== Scripted fields
139
139
140
-
The next piece show how to use a scripted field to calculate and return the age of the persons.
141
-
Scripted fields can only add something to the returned data, the age cannot be used in the query (see runtime fields for that).)
140
+
The next piece shows how to use a scripted field to calculate and return the age of the persons.
141
+
Scripted fields can only add something to the returned data, the age cannot be used in the query (see runtime fields for that).
142
142
143
143
====
144
144
[source,java]
@@ -212,12 +212,12 @@ In the following code this is used to run a query for a given gender and maximum
212
212
}
213
213
----
214
214
215
-
<.> define the runtime field that caclulates the // see https://asciidoctor.org/docs/user-manual/#builtin-attributes for builtin attributes.
215
+
<.> define the runtime field that calculates the age of a person. // see https://asciidoctor.org/docs/user-manual/#builtin-attributes for builtin attributes.
216
216
<.> when using `Query`, add the runtime field.
217
217
<.> when adding a scripted field to a `Query`, an additional field parameter is needed to have the calculated value returned.
218
218
<.> when adding a scripted field to a `Query`, an additional source filter is needed to also retrieve the _normal_ fields from the document source.
219
219
<.> get the data filtered with the query and where the returned entites have the age property set.
220
220
<.> when using the repository, all that needs to be done is adding the runtime field as method parameter.
221
221
====
222
222
223
-
In addition to define a runtime fields on a query, they can also be defined in the index by setting the `runtimeFIeldPath` property of the `@Mapping` annotation to point to a JSON file that contains the runtime field definitions.
223
+
In addition to define a runtime fields on a query, they can also be defined in the index by setting the `runtimeFieldsPath` property of the `@Mapping` annotation to point to a JSON file that contains the runtime field definitions.
0 commit comments