Provide suggestions in the search box - Fluid Topics - Latest

Integrate the Fluid Topics API

Category
Technical Notes
Audience
public
Version
Latest

The Suggest feature proposes document and topic titles while users type the first characters of a keyword in the search box.

For example, when typing the first two characters of "administration", Fluid Topics suggests the following content:

Suggested search results

The Suggest web service returns matching publications and topics based on suggestions entered by end-users:

/api/khub/suggest

It is possible to integrate the Suggest web service to use it in an external interface, as in the following image:

Integrate the Suggest web service

The following lines show an example of implementing the Suggest web service in PHP:

<?php
...
public function get_suggest( $query = null )
  ...
    $data = array(
       "input" => $query,
       "contentLocale" => "en-US"
       );
    ...
    $url = $this->tenant . "/api/khub/suggest";
...
?>

It is necessary to statically or dynamically define the tenant URL with the API path.

The following example shows an HTML file that embeds the Suggest web service:

<html>
...
$('#search-text').autocomplete({
      source: "example_use_suggest.php",
      minLength: 1
});
...
</html>