Add a parameter to the query request
Add a parameter to the query response
This example contains a simple JavaScript function which copies information from thectx
(Context) object into the query response. Requirements:
- The
response
parameter cannot be used in query pipeline stages prior to the Solr query stage. This example assumes use in a later stage. - The
response.initialEntity.appendStringList()
function only works if the query’swt
(writer type) parameter is set to json or xml, for example:wt=json
.
Java object interactions
The default JavaScript engine used by Fusion is the Nashorn engine from Oracle. See The Nashorn Java API for details. In Fusion 5.9.6 and up, you also have the option to select OpenJDK Nashorn. While Nashorn is the default option, it is in the process of being deprecated and will eventually be removed, so it is recommended to use OpenJDK Nashorn when possible. You can select the JavaScript engine in the pipeline views or in the workbenches. Your JavaScript pipeline stages are interpreted by the selected engine.
typeof(object)
will not give meaningful results. Instead, you can use JavaScript to discover the Java type of an object. Once you know the Java type of an object, you can refer to the Fusion Pipeline Javadocs to learn more about the Java type and how to use Java Objects.