|
@@ -42,6 +42,38 @@ front, and can use runtime fields to amend the mapping at any time. Using
|
|
|
runtime fields allows for a smaller index and faster ingest time, which
|
|
|
combined use less resources and reduce your operating costs.
|
|
|
|
|
|
+[discrete]
|
|
|
+[[runtime-incentives]]
|
|
|
+=== Incentives
|
|
|
+Runtime fields can replace many of the ways you can use scripting with the
|
|
|
+`_search` API. How you use a runtime field is impacted by the number of
|
|
|
+documents that the included script runs against. For example, if you're using
|
|
|
+the `fields` parameter on the `_search` API to
|
|
|
+<<runtime-retrieving-fields,retrieve the values of a runtime field>>, the script
|
|
|
+returns only the top hits just like script fields do.
|
|
|
+
|
|
|
+You can use <<script-fields,script fields>> to access values in `_source` and
|
|
|
+return calculated values based on a script valuation. Runtime fields have these
|
|
|
+same capabilities, but provide greater flexibility because you can query and
|
|
|
+aggregate on runtime fields in a search request. Script fields can only fetch
|
|
|
+values.
|
|
|
+
|
|
|
+Similarly, you could write a <<query-dsl-script-query,script query>> that
|
|
|
+filters documents in a search request based on a script. Runtime fields provide
|
|
|
+a very similar feature that is more flexible. You write a script to create
|
|
|
+field values and they are available everywhere, such as
|
|
|
+<<search-fields,`fields`>>, <<query-dsl, all queries>>, and
|
|
|
+<<search-aggregations, aggregations>>.
|
|
|
+
|
|
|
+You can also use scripts to <<script-based-sorting,sort search results>>, but
|
|
|
+that same script works exactly the same in a runtime field.
|
|
|
+
|
|
|
+If you move a script from any of these sections in a search request to a
|
|
|
+runtime field that is retrieving values from the same number of documents, the
|
|
|
+performance should be about the same. The performance for these features is
|
|
|
+largely dependent upon the calculations that the included script is running and
|
|
|
+how many documents the script runs against.
|
|
|
+
|
|
|
[discrete]
|
|
|
[[runtime-compromises]]
|
|
|
=== Compromises
|