Scoped search allows you the power to limit a visitor's search to a section or type of content within the website instead of searching across the whole index. By making an adjustment to your Cludo javascript, you can ensure only results from a specific category, domain, and so forth appear when a search is done on a specific set of pages, without having to create a new engine.
Step 1: Set up a Custom Field
To set up a scoped search, you will need to set up a custom field in the Crawler settings to pull the content you'd like to base your filter on (for example, a meta tag, XPath, URL, etc.).
Go to Settings in your MyCludo Dashboard and select Crawlers.
Select the crawler you'd like to filter search results for.
In Step 3, (Fields to be crawled for Content Pages), select Add Custom Field. Set the value for the filtered pages using any of the following options:
- Open graph tag
- Cludo meta tag
- Meta tag
- URL match
- XPath
Set the Field title to the naming convention you'd like to call the custom field.
Is required will require that the custom field be present to index. It is not recommended that this is a required field for scoped searches.
In Step 4, Test your Search by inserting different URLs to ensure the custom field is being pulled correctly. In this example, the custom field set is SubDirectory and the value is publicworks.
Hit Save to updated your crawler settings and to kick off a new crawl so that the crawler can begin indexing that custom field.
Step 2: Update the Cludo Javascript for the sections of the websites you'd like scoped search on
To update the Cludo javascript for scoped searches, you will need to update a line of javascript in your existing Cludo implementation. Generate this script by going to your Search Configurations or submit a support ticket for our team to help identify this script for you.
Add the filter to the script by going to the CludoSettings and adding the following line:
filters: {"CUSTOM FIELD NAME": ["CUSTOM FIELD VALUE"]},
For example, to create a scoped search for the publicworks pages on cludocounty.gov, the javascript would be updated to add the filter:
<script type="text/javascript" src="//customer.cludo.com/scripts/bundles/search-script.min.js"></script>
<script>
var CludoSearch;
(function () {
var cludoSettings = {
customerId: 0000,
engineId: 0000,
searchUrl: 'https://cludocounty.gov/results',
language: 'en',
searchInputs: ['cludo-search-box'],
type: 'inline',
filters: {"SubDirectory": ["publicworks"]},
hideSearchFilters: true,
searchApiUrl: 'https://api-us1.cludo.com/api/v3'
};
CludoSearch= new Cludo(cludoSettings);
CludoSearch.init();
})();
</script>
Install the script where you'd like to implement a scoped search.
If you have any questions, please do not hesitate to contact us at support@cludo.com!
Comments
0 comments
Please sign in to leave a comment.