Skip to main content
The REST Query index stage performs remote procedure calls to external services, merges the response from that service with a document being processed by the pipeline, and makes calls to the external system for each document. In Fusion version 3.0 and earlier, the stage is called the Query REST Remote Procedure Calls (RPC) Client stage. This stage can call external systems in any of the following ways:
  • any HTTP or HTTPS request: <http-protocol>://<path>
  • a Solr request: solr://COLLECTION_NAME/…​
  • a Fusion service request: extservice://SERVICE_NAME/<path>
The call syntax allows the use of document field variables. For example, <doc.docField> is replaced with the value of the field named docField for the document being processed. Several types of responses are also supported:
  • POJOs
  • JSON
  • XML

Call Parameters

In the Fusion UI, select include to display the fields for the call parameters (params in the REST API). Parameters are specified as key-value pairs: The uri, queryParams, headers, and entity values support template expressions, such as <doc.fieldName> for a field in the current document or <ctx.key> for a pipeline context value. A multi-valued field returns all of its values, concatenated with no separator. To use only the first value, use <first(doc.fieldName)>. If a referenced field is missing from the document, the expression evaluates to an empty string.
The ${fieldName} syntax is deprecated. Do not use it. Stages that use it log a deprecation warning, and support will be removed in a future version.
If your stage configuration uses ${fieldName}, migrate it to template expressions:
  1. In the uri, queryParams, headers, and entity values, replace each ${fieldName} with <first(doc.fieldName)>. For example, change ${url} to <first(doc.url)>. <first(...)> keeps the legacy behavior of using only the first value of a multi-valued field. For single-valued fields, <doc.fieldName> returns the same result. Don’t use ${doc.fieldName}. That syntax looks for a field literally named doc.fieldName, which is treated as a missing field.
  2. Replace every ${...} reference in a value at the same time. If a value contains a ${...} reference, the stage doesn’t evaluate template expressions in that value.
  3. Check how the stage should handle missing fields. With ${fieldName}, a missing field in uri skips the call, a missing field in queryParams or headers omits that entry, and a missing field in entity becomes an empty string. With template expressions, a missing field becomes an empty string and the call still runs. To skip documents that don’t have the field, set the stage Condition to an expression such as doc.hasField("url").
  4. Save the stage and confirm that the deprecation warning no longer appears in the logs.
For example, a queryParams could be constructed as follows:
In this example, <doc.prodName> is replaced with the value of the prodName field in the current document. If the current document contains “iPhone 6” as the value of ‘prodName’, the resulting query in this example will be a fielded search q=a_txt:iPhone 6.

Mapping Rules

The mappingRules property takes the following, specified as key-value pairs:
  • path. an XPath expression. It is assumed that this expression always returns a node list, and each returned node is processed separately and its converted value is added to a multi-valued field.
  • target. the name of the target field in the current document where the value(s) will be stored.
  • append. if true, values extracted from the RPC response will be appended to the target multi-valued field. When this is false, the default, existing values in the target field will be discarded and replaced with the values from the RPC response.
  • xml. if true, the extracted DOM nodes will be separately serialized to XML and the resulting XML-formatted text will be added to the target field. When this is false, the default, the extracted DOM nodes will be flattened and converted to a list of fields. Field names in this case will correspond to XML element names, dot-separated, and element attributes will be represented as fields with @attributeName suffix.

Examples

Create a REST Query stage to merge results from another Solr system:
Upload a stopword list:

Configuration

When entering configuration values in the UI, use unescaped characters, such as \t for the tab character. When entering configuration values in the API, use escaped characters, such as \\t for the tab character.