The JDBC Lookup query pipeline stage is used to call out to a database as part of a pipeline stage, to inject results into either the context/request or the pipeline document.
For example, if you needed to look up a user from a DB and add their profile information onto a request for downstream use in a pipeline, the JDBC Lookup Stage would facilitate this.
You must first upload a JDBC Driver to Fusion.
Upload a JDBC Driver to Fusion
The JDBC V2 connector is supported, and fetches documents from a relational database via SQL queries. Under the hood, this connector implements the Solr DataImportHandler (DIH) plugin.Fusion stores JDBC drivers in the blob store. You can upload a driver using the Fusion UI or the Blob Store API.
Upload the JAR file to Fusion’s blob store using the /blobs/{id} endpoint.Specify an arbitrary blob ID, and a resourceType value of plugin:connector, as in this example:
Fusion automatically publishes the event to the cluster, and the listeners perform the driver installation process on each node.
If the blob ID is identical to an existing one, the old driver will be uninstalled and the new driver will installed in its place. To get the list of existing blob IDs, run: curl -u USERNAME:PASSWORD https://FUSION_HOST:FUSION_PORT/api/blobs
An example of setup for a JDBC Lookup query pipeline stage.Upload stage config via POST to Fusion REST API endpoint api/query-stages/instances
Copy
curl -u USERNAME:PASSWORD -X POST -H "Content-Type: application/json" -d '{"id": "jdbc-quer","type":"jdbc-query-lookup","driver":"postgresql-9.3-1101-jdbc4.jar","connection":"jdbc:postgresql:database","username":"user","password":"password1","preparedStatement":"select ID as id from DATABASE;"}' http://FUSION_HOST:FUSION_PORT/api/query-stages/instances
Stages can be triggered conditionally when a script in the Condition field evaluates to true.
Some examples are shown below.Run this stage only for mobile clients:
Copy
params.deviceType === "mobile"
Run this stage when debugging is enabled:
Copy
params.debug === "true"
Run this stage when the query includes a specific term:
The first condition checks that the request parameter “fusion-user-name” is present and has the value “SuperUser”.
The second condition checks that the request parameter “isFusionPluginQuery” is not present.
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.