Search with Search Clusters - Fluid Topics - 3.4 - Technical Notes

Integrate Fluid Topics APIs

Product
Fluid Topics
FT_Version
3.4
Category
Technical Notes
language
English
audience
public

Searching with clusters consists in defining facets to get clustered search results. For example, by it is possible to cluster search results based on the product they concern.

By using the Global Clustered Search web service, it is possible retrieve all information contained in all documents directly from the Fluid Topics server:

/api/khub/clustered-search

The web service returns a list of all matching documents for all versions. Users can select a facet to cluster results by version, for example, and view the number of documents available for each facet value.

The following image shows how the results available in a turnkey Fluid Topics portal can be displayed in another portal with clustering applied:

Clustered search

The following image demonstrates how it is possible to display tags with with the number of matching results for each facet:

Clustered search and facets

The following lines show an example of a Global Clustered Search web service implementation in PHP. Product and AFS_Version facets are defined as cluster criteria:

<?php
...
if( is_null( $filter ) )
$filter = array();
$data = array(
"query" => $query,
"contentLocale" => "en-US",
"paging" => array( "page" => $page, "perPage" => 20 ),
"facets" => array(array("id" => "Product"),array("id" => "AFS_Version")),
"filters" => $filter
);
...
$url = $this->tenant . "/api/khub/clustered-search";
...
?>

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

The following example shows an HTML file embedding the Global Clustered Search web service:

<html>
<head>
<style>...</style
</head>
<body style="background-color: azure;">
<div id="search">...</div>
...
<script>
$('#query').autocomplete({...});

...

function Search(){
data = {...};
$.get(
'example_use_search.php',
...;
$('.facet').jstree();
$('#facet1').on("changed.jstree", function (e, data) {...});
$('#facet2').on("changed.jstree", function (e, data) {...});
$('#facet3').on("changed.jstree", function (e, data) {...});
...
}
);
}
</script>
</body>
</html>