Sitecore Connector

Sitecore Hawksearch Connector for Helix Projects: Initial Setup Notes


Configure Hawksearch in Your Solution

For your site to know where to fetch search results from, it needs to know the engine name, API key, API URL, tracking key, tracking URL, and recommender URL. While not all of these may needed for your project, the engine, API key, and API URL are needed for it to function.

Look at the Feature.HawkSearch.config file and review the following settings:


Setting name

Where to find in Hawksearch

Setting name

Where to find in Hawksearch


The root URL of the Hawksearch admin page


Admin > Site-Specific System parameters > Configuration > Tracking URL


Admin > Account Info > Tracking Key


N/A: This is currently unused in the connector but should be set if required by the Hawksearch project

Copy the Feature.HawkSearch.SITE.config.example file to App_Config/Include/Feature/Feature.Hawk and rename it appropriately. Update the following configuration settings:


Path to setting

Where to find in Hawksearch

Path to setting

Where to find in Hawksearch


Defined by you. Usually begins with “hawk_”


Admin > Account Info > Engine Name


Admin > Account Info > API Key


N/A: This is the ID of the Sitecore item where the crawler will begin its search in the content tree.

Configure Unicorn Serialization

The required Sitecore items are added to your project with Unicorn. Update the physicalRootPath attribute of the unicorn/configurations/configuration/targetDataStore element to match the physical location of the serialization folder on your computer. Sync the project by going to /unicorn.aspx on your local site.

Define the Default Hawksearch Index

Find the site definition for the “website” site (or whatever base/parent site definition you have defined) in your SiteDefinition.config file. Add an attribute “hawkDefaultIndex” and set it to the same value as the id attribute of the indexes/index configuration defined in Feature.HawkSearch.SITE.config.

Enable Attribute Routing

The Sitecore.Feature.Hawksearch project uses attribute routing. Make sure this is enabled in your project. Add this class somewhere in a project in the Project layer.

1 2 3 4 5 6 public class MapAttributeRoutes { public void Process(PipelineArgs args) { RouteTable.Routes.MapMvcAttributeRoutes(); } }

Add a configuration file to add it to the initialize pipeline


1 2 3 4 5 6 7 8 9 <configuration xmlns:patch=""> <sitecore> <pipelines> <initialize> <processor type="MySite.Pipelines.Initialize.MapAttributeRoutes,McGuireWoods.Website" patch:before="processor[@type='Sitecore.Mvc.Pipelines.Loader.InitializeControllerF actory, Sitecore.Mvc']" /> </initialize> </pipelines> </sitecore> </configuration>

Include the Auto Suggest Rendering

For Hawksearch to work properly, you have to include the appropriately named Auto Suggest rendering to the bottom of every page on your site. The easiest way to do this with Sitecore is to paste and modify the following code on the bottom of your layout file.


1 2 3 4 5 @Html.Sitecore().Rendering(Sitecore.Feature.HawkSearch.Constants.RenderingIds.AutoSugg est, new { Parameters = string.Format("{0}=id_of_search_bar_input", Sitecore.Feature.HawkSearch.Constants.Strings.RenderingParams.KeywordInputId), Cacheable = true, CacheKey = "unique_cache_key" })

Replace the id_of_search_bar_input with the id of the search bar input element.

Create the Search Bar Input Field

A search request should redirect the user to whatever page has the Search Results and/or Search Facet renderings on it in Sitecore. There should be a GET parameter “keyword” with the search query.

The easiest way to do this is to have the search box be inside a form element that has its action set to the search page and the search bar “name” attribute set to “keyword.” Make sure “id” matches the id used in the Auto Suggest rendering include above.

1 2 3 4 5 6 7 <form action="/search" method="get"> <div class="form-group"> <label for="id_of_search_bar_input" class="sr-only">Search</label> <input type="text" id="id_of_search_bar_input" name="keyword" placeholder="Search"> <input type="submit" value="Search" /> </div> </form>

If you have more than one search bar on a page and want to enable a different custom Auto-suggest div element for both of search bars, you must set the “data-auto-suggest-selector” attribute to a jQuery selector matching the other custom Auto-suggest div element.

You must also include a second Auto-Suggest rendering which uses the ID of this other search bar so Auto- suggest is initialized multiple times for all search bars.

1 2 3 4 5 6 7 <form action="/other-search" method="get"> <div class="form-group"> <label for="other_site_search" class="sr-only">Search</label> <input type="text" id=" other_site_search" name="keyword" placeholder="Search" data-auto-suggest-selector="div.other-autocomplete-area"> <input type="submit" value="Search" /> </div> </form>

Build the Hawksearch Index

You rebuild your hawk index from the Indexing Manger in the Control Panel section of the Sitecore backend. It will have the same name as whatever you named the index in the Feature.HawkSearch.SITE.config file. Check the box next to the hawk index and press “Rebuild.”

If you get an error message, try to create the Data/hawksearch folder manually and ensure that the crawler’s root item (defined in the Feature.HawkSearch.SITE.config file) exists in the database it uses.

Once it rebuilds, you should see newly generated feed files in the Data/hawksearch/[Engine name] folder.

Managing Feeds

After installing the Sitecore package you will see a shortcut on the Sitecore Launchpad.

This is a shortcut to the HawkSearch portal.

The URL this shortcut navigates to is determined by the value of this Sitecore Setting for the environment:

<setting name="Sitecore.Feature.HawkSearch.Api.Url" value="" patch:source="Feature.HawkSearch.config"/>

HawkSearch re-indexing can be scheduled to run periodically using Sitecore Tasks.

After installing the Sitecore Package there will be a Sitecore Task for which you can adjust frequency of index rebuilds. Common rebuild frequencies range from once a day to every 2 or 4 hours. Time to execute a re-index varies based on size of data and complexity of computed fields. A typical full rebuild take 2-3 minutes.

To rebuild a Hawk Index manually, simply use the Sitecore Indexing Manager.

Select the desired index and hit Rebuild just like any other Sitecore index.

How to Configure Data Feeds

“How do we configure the feeds?”… It is by using the Sitecore index configuration layer just like any other Sitecore solr or azure index.

This is where the implementation effort exists on the Sitecore side for preparing the data feeds.

Reference: Feature.HawkSearch.DefaultIndexConfig.config

And see: Feature.HawkSearch.SITE.config.example