Searching with clusters consists in defining facets to get clustered search results. For example, it is possible to cluster search results based on the product they concern.
By using the 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:
The following image demonstrates how it is possible to display tags with with the number of matching results for each facet:
The following lines show an example of a Clustered search web service implementation in PHP. The 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 Clustered search web service:
<html>
<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>