Step 4: Create a REST endpoint

This step will show you how to create a REST endpoint in Matrix. There are steps in Funnelback, and in Matrix.

Funnelback-side requirements

To create your REST endpoint, you will need the URL of your Funnelback search test. These instructions take place in your Funnelback instance:

  1. Go to your search package page:

    1. Select Admin Dashboard.

    2. Select your search package.

  2. Scroll down to the Components section.

  3. Select the Results Pages tab.

  4. Select the search icon This image shows the magnifying glass search icon.

  5. Select Search Live from the drop-down menu.

    It is important to select Search Live so that the URL you copy references the published version of the template.

    This image shows the results pages tab with the search icon drop-down menu expanded.

  6. Copy the URL from the test search page.

    This image shows the results page with the URL highlighted

Matrix-side instructions

These commands take place in your Matrix instance.

Create the REST asset

  1. Right-click on the Designs site asset.

  2. Select Create new…​  Web Services  REST resource.

  3. Give the REST resource a name. This image shows the pop-up window that allows you to enter a name for the REST resource asset.

  4. Select Create.

Edit the REST asset.

  1. Right-click on the REST asset. Select Details.

  2. Select Edit

  3. Set the method to GET.

  4. Configure the URL in the following way:

    1. In the HTTP request section, paste the \https://[domain]/s/search.html part of the URL of your Funnelback search test that you copied above.

    2. Add the following parameters to the end of the URL. They use Matrix keyword replacement to efficiently manage the search:

      %globals_server_query_string^replace:profile=[RESULTS-PAGE-ID]:^replace:collection=[SEARCH-PACKAGE-ID]:^replace:&+:&%&collection=[SEARCH-PACKAGE-ID]&profile=[RESULTS-PAGE-ID]
      1. Replace both occurrences of [RESULTS-PAGE-ID] with the alphanumeric Funnelback results page ID from the copied URL.

      2. Replace both occurrences of [SEARCH-PACKAGE-ID] with your collection ID.

        When you have finished, Your URL will look similar to this:

        http://dxp-us-search.funnelback.squiz.cloud/s/search.html?collection=1ee8293e-73e2-0000-982f-9b977c481d4e~sp-dx-dev-test&profile=dx-dev-test-results&%globals_server_query_string^replace:profile=dx-dev-test-results:^replace:collection=1ee8293e-73e2-0000-982f-9b977c481d4e~sp-dx-dev-test:^replace:&+:&%

        The URL will reflect the region that you are working in.

        You must ensure that the domain is a search domain, so you may have to edit the domain part of the URL to your search domain.
  5. Add the following to the Request Header field to pass the remote user’s IP address to Funnelback for search analytics:

    X-Forwarded-For:%globals_server_remote_addr%
    This setting will allow Funnelback search analytics to identify the IP address of the user. Passing the IP address of the user ensures that Funnelback search analytics are accurate.
  6. Select the Follow Redirects setting.

  7. Select the Enable HTTP Compression setting.

  8. Select the Append Query String setting.

  9. Select Save.

In your Funnelback instance, you will need to add configuration parameters to your results page. These parameters print the Funnelback output to your search results page.

  1. On your Funnelback dashboard, find your search package and select the Results page tab.

  2. In the Customize section, select Edit results page configuration.

    This image shows the Customize section of the results page dashboard

  3. Enter the following configuration parameters into the Parameters page. Leave the environment field as All:

    Parameter key Value Value source

    ui.modern.search_link

    /fb_testsite/search

    The root relative path to the search page in your Matrix site.

    ui.modern.click_link

    https://<domain>-us-search.funnelback.squiz.cloud/s/redirect

    Identifies the URL used to log result clicks.

    The Parameter key field is pre-loaded with common parameter keys. Put your cursor into the parameter key field and begin typing. Scroll through the results until you find the parameter you want. Select the parameter and it will be populated in the Parameter key field.

    This image shows the cursor on the parameter key

  4. When you have entered the values, select Save.

Update the disallow list in your robots.txt file

You now need to add the URL of your REST asset to the disallow list in your robots.txt file. This is to prevent Funnelback from performing a crawl of the search results.

  1. Right-click on the REST asset and select Details.

  2. Copy the URL from the browser.

    This image shows the append query string setting with the check box selected.

  3. Add the URL to the disallows list in your robots.txt file.

Test the REST endpoint

Test your REST endpoint to make sure that it works:

  1. Right-click on the Search search page.

  2. Select Preview  In new window.

    This image shows the drop-down menu displayed when the use right-clicks on the Search asset. The Preview drop-down is shown with In new window highlighted.

  3. Enter !null into the Search field so that you get all the results from the crawl.

  4. Your results page will look like this:

    This image shows the search results page.