Using the REST V2 Connector
The quick learning for Using the REST V2 Connector focuses on how to ingest a datasource using REST V2 connector recipes.
JSON guide
REST V2 recipes are JSON files appended to cURL calls that can be sent to Fusion, where their contents show up in the UI. From there, Fusion can use the APIs created by external software companies to crawl the content stored in those datasources. The way the JSON is set up allows the REST V2 connector to work with multiple different products, attesting to its flexibility. This article breaks down the different parts of a recipe’s JSON file and how it can be used when creating a Fusion datasource. The structure and parameters included will vary, but you can use this guide as a reference for information that has been used in some of the recipes. A parent request, also referred to as a root request, is set using the path for an endpoint. Child requests drill further down into an endpoint and can be looped through to add more information to the documents in the index. This is useful when the content being crawled has additional objects that are not picked up by the parent request alone, for example, comments on pages. A cURL call to the REST V2 connector has headers to use within the request definition that include content type and authorization to Fusion. Calls for the REST V2 connector go through the Connector Datasources API. Here is an example call. The headers in this call are used to define the content type as JSON and to enter your Lucidworks login details. Replace:FUSION_HOST:FUSION_PORTwith your Fusion address.AUTHORIZATION_CREDENTIALSwith your Lucidworks login information in Base64.JSON_RECIPEwith the preconfigured recipe obtained from GitHub, making sure to update any placeholders found in that recipe.
General parameters
The JSON recipe contains connector information with the general parameters used to handle the service. This table contains a selection of parameters that you might see.Properties
The properties section of the JSON file contains the bulk of the information being sent and includes the API base URL, authentication mode, service endpoints, HTTP method, query parameters, pagination settings, and any loop configurations.API base URL
Authentication mode
The authentication mode in the JSON body request contains the way to authenticate using the API. This will be the login information for the external service. For example, if indexing content from Confluence, you would use this section to include your Confluence login details.Service endpoints and list of requests configuration
The service endpoints section (serviceEndpoints), known as list of requests configuration in some recipes (requestConfigurations), specifies the API endpoint paths appended to the base URL (serviceURL) used to crawl a datasource. Query parameters will not work if added directly in the endpoints, so be sure to include any query parameters using queryKey and queryValue fields, as the query fields are mapped to Solr using a queryKey and populated with results from queryValue.
Parent (root) requests
Parent requests target an API endpoint to crawl content. These endpoints are higher in the structure than child requests (described below), which are used to crawl objects embedded at a deeper level to add more content to a document being indexed.Pagination
Pagination has two options: pagination by next page URL and pagination by batch size. For pagination by next page URL, the URL that starts the next page is sent by the request. For pagination by batch size, you can configure pagination in the query parameters by indicating the start number of the index and the batch size.Root response mapping
Root response mapping is used to separate the parent objects being crawled into individual Solr documents by assigning each document a unique ID. The data obtained from child requests is added to the same document by association with this parent ID. This is also the area where you can choose to index content other than text by enablingbinaryResponse. For attachments, ensure Send as Binary Response is enabled. If it is not, then no attachments are received and indexed. When enabled, the connector looks for MIME type other than .json for attachments to index. For a JSON response, ensure Send as Binary Response is not enabled.
Loops using child requests
Loops, also known as child requests, contain an array of queries to extract more information from a datasource for the documents being indexed. The loop will iterate over the data request for each parent ID and associate the response with the parent. This is useful in cases where the parent endpoint has additional endpoints that can be appended for data contained further down within the endpoint path. Loops perform a separate request for each data object. The REST V2 connector supports hierarchical discovery, meaning when content is located, that content is recursively checked to see if it has additional information associated with it for the child request and will continue collecting information for each request until no more content is located. For example, if the connector is crawling for comments and attachments, it will check each of those items for any comments and attachments connected to them. If any are found it will check for comments and attachments associated with those, and continue until all relevant content is collected. This is also useful in cases where the connector is searching through folders with multiple levels of subfolders.Child response mapping
The child responses are mapped to the parent through thedataId and dataPath in the root response mapping described earlier through the use of a parentIdKey. The parentIdKey should match the dataId in the root response mapping.
For example, with root response mapping:
Other mappings
Additional mapping configures the data objects. Recipes do not necessarily include all parameters described here.App settings
The rest of the JSON can include settings for the collection name, pipeline name, and connector type.Advanced settings in the UI
Within Fusion, opening the datasource and enabling the Advanced toggle displays optional settings to be applied. Under Core Properties > Fetch Settings you can modify the settings to help control the speed at which the connector crawls the source. For example, increasing Fetch Threads might increase the crawl speed. Setting timeout limits can be useful to end a crawl when something is causing the crawl to get hung up.How to get a recipe into Fusion
This section shows how to get a recipe from GitHub into Fusion. Recipes are JSON files used as a quick method to update a Fusion datasource.- Open the REST V2 connector public GitHub repository.
- Locate the recipe you want and open the file.
- Copy the JSON.
-
Add the JSON as the body to a call to the Connector Datasources API.
An example cURL call looks like this: -
In the above, replace:
FUSION_HOST:FUSION_PORTwith the URL of your Fusion instance.APP_NAMEwith the name of the app you are using in Fusion.AUTHORIZATION_CREDENTIALSwith your Lucidworks login information in Base64.JSON_RECIPEwith the recipe you copied from GitHub.
-
Change the following in the JSON:
id: This populates the Configuration ID for the connector in the Fusion UI and sets the name of the datasource. You can keep the default or choose a different name to fit your needs.serviceURL: API base URL from where the data is extracted. Change this to match your own datasource URL.passwordanduser: Change these values to your login information.collection: This must match the name of the Fusion app that you are using.- Any other values marked for replacement, such as
parserIdorpipeline.
- Once values are changed, send the API request.
- Log into Fusion in a web browser and open the app associated with the request.
-
Go to Indexing > Datasources and select the REST V2 connector in the list with the
idas the name of the datasource. - Make any additional changes within the UI.
- If indexing content other than text, for example images and attachments, select Send as Binary Response.
- Save the datasource.
- After it saves, you can click Run > Start to begin indexing.