Note |
---|
This information is for older versions of Hawksearch and not the latest v4.0. This is not compatible with the Search Api or Indexing Api. Please contact Hawksearch for more information |
Table of Contents
Table of Contents |
---|
...
Hawksearch has three environments available: Development, Staging/Test and a load-balanced Production. When performing integration, each engine can be accessed by using these domains:
Development Environment
When including the scripts below, please use the appropriate domains for the development environment.
Hawk URL: http://dev.hawksearch.net/
Tracking URL: http://tracking-dev.hawksearch.net/
Recommendations URL: http://recs-dev.hawksearch.net/Staging/Test Environment
When including the scripts below, please use the appropriate domains for the test environment.
Engine Reference URL: http://test.hawksearch.net/
Tracking URL: http://tracking-test.hawksearch.net/
Recommendations URL: http://recs-test.hawksearch.net/Production Environment
When including the scripts below, please use the following domain for the production/live environment.
Engine Reference URL: http://yourenginename.hawksearch.com/ Provided at time of launch.
Tracking URL: http://tracking-na.hawksearch.com/
Recommendations URL: http://recs-na.hawksearch.com/
...
Sample Hawksearch Engine
As reference, a sample Hawksearch engine exists to test out API usage. This engine exists at:
...
API Response Examples below display what properties are returned for each element.
Pagination Object
Expand | |||||
---|---|---|---|---|---|
| |||||
|
Sorting Object
Expand | ||
---|---|---|
| ||
|
Results Object
Expand | |||||
---|---|---|---|---|---|
| |||||
|
Facets Object
Expand | |||||
---|---|---|---|---|---|
| |||||
|
Selections Object
Code Block |
---|
"Selections": { "department": { "Label": "Department", "Items": [ { "Label": "Kids", "Value": "Kids" } ] } } |
...
If Location is not blank, a Redirect Rule generated a target URL for the visitor to go to.
Code Block |
---|
"location": ""
|
...
XML
Using the sample engine, you can access the XML response via this URL:
...
VB.Net Code Sample
Code Block | ||
---|---|---|
| ||
Dim qs As URLParameters = New URLParameters(HttpContext.Current.Request.QueryString, "ajax;json;guid;PageId") Dim HawkSearchUrl As String = “http://dev.hawksearch.net/sites/enginename” Dim URL As String = HawkSearchUrl & "/" & qs.ToString() Dim r As HttpWebRequest = WebRequest.Create(URL) If Request IsNot Nothing Then r.UserAgent = Request.UserAgent r.Headers.Add("HTTP_TRUE_CLIENT_IP", Request.UserHostAddress) End If Dim myCache As New System.Net.CredentialCache() myCache.Add(New Uri(URL), "Basic", New System.Net.NetworkCredential(AppSettings("WindowsAuthLogin"), AppSettings("WindowsAuthPassword"))) r.Credentials = myCache Dim resp As System.Net.HttpWebResponse = r.GetResponse() Dim sr As Dim sr As New System.New System.IO.StreamReader(resp.GetResponseStream()) Dim html As String = sr.ReadToEnd() sr.Close() |
...
SEO
In order to improve SEO on the site please make sure the search page has been added to the robots.txt on your site and disallowed so search engines do not reach it. There should always be a no index/no follow on the search pages. For improving SEO functionality on the site for popular search terms ask us more about the SEO Booster functionality we offer.
...
Info |
---|
To lookup the Engine Name and Tracking Key for your account please look in the Hawksearch workbench under Admin >> Account Info. |
Code Block | ||
---|---|---|
| ||
<!-- Hawksearch Header Includes --> <script type="text/javascript"> //<![CDATA[ (function (HawkSearch, undefined) { HawkSearch.HawkUrl = 'http://dev.hawksearch.net/sites/enginename'; HawkSearch.TrackingUrl = 'http://tracking-dev.hawksearch.net'; HawkSearch.RecommenderUrl = 'http://recs-dev.hawksearch.net'; HawkSearch.ClientGuid = 'tracking_key'; if ("https:" == document.location.protocol) { HawkSearch.HawkUrl = HawkSearch.HawkUrl.replace("http://", "https://"); HawkSearch.TrackingUrl = HawkSearch.TrackingUrl.replace("http://", "https://"); HawkSearch.RecommenderUrl = HawkSearch.RecommenderUrl.replace("http://", "https://"); } }(window.HawkSearch = window.HawkSearch || {})); var hawkJSScriptDoc = document.createElement("script"); hawkJSScriptDoc.async = true; hawkJSScriptDoc.src = HawkSearch.HawkUrl + '/includes/hawksearch.min.js?v1.0'; var hawkJSTag = document.getElementsByTagName('script')[0]; hawkJSTag.parentNode.insertBefore(hawkJSScriptDoc, hawkJSTag); var hawkCSSScriptDoc = document.createElement("link"); hawkCSSScriptDoc.setAttribute("rel", "stylesheet"); hawkCSSScriptDoc.setAttribute("type", "text/css"); hawkCSSScriptDoc.setAttribute("href", HawkSearch.HawkUrl + '/includes/hawksearch.css'); document.head.appendChild(hawkCSSScriptDoc); //]]> </script> |
...
To enable it on your page, there are two steps:
Add the Auto-Complete JavaScript block to the end of the <BODY> tag.
textboxname is the ID of the search text box. Look to your existing HTML code to add the matching ID.
textboxnamefooter is the ID of the search text box if you have one on the footer. Look to your existing HTML code to add the matching ID.
Code Block | ||
---|---|---|
| ||
<!-- Hawksearch - Auto-Suggest --> <script type="text/javascript"> //<![CDATA[ HawkSearch.initAutoSuggest = function () { HawkSearch.suggestInit('%%textboxname%%', { lookupUrlPrefix: HawkSearch.HawkUrl + '/?fn=ajax&f=GetSuggestions', hiddenDivName: '', isAutoWidth: true }); HawkSearch.suggestInit('%%textboxnamefooter%%', { lookupUrlPrefix: HawkSearch.HawkUrl + '/?fn=ajax&f=GetSuggestions', hiddenDivName: '', isAbove: true }); }; //]]> </script> |
Autocomplete Integration:
The autocomplete feature can be integrated through API similar to the search functionality. Hawksearch sends the response in JSON format which can be consumed by your website and displayed appropriately.
Request: GET request made through a URL built as follows:
https://DOMAIN_URL/ENGINE_NAME/?fn=ajax&f=GetSuggestions&q=KEYWORD&hawkoutput=json
Parameter | Description | Value |
---|---|---|
fn | Indicates ajax request | ajax |
f | The function name to be called | GetSuggestions |
q | The keyword. This is the text typed by the user | user-entered alphanumeric value |
hawkoutput | Indicates the format of the response | json |
Response: Response is a JSON object sent back to the caller.
Expand | |||||
---|---|---|---|---|---|
| |||||
|
Parameter | DataType | Details |
---|---|---|
Count | Numeric | Total products available for the keyword |
ContentCount | Numeric | Total content items available for the keyword |
Categories | Array of Category Objects | Every category object is a category suggestion: |
Products | Array of Product | Based on the request parameter DisplayFullResponse, the product object has all its fields output or the standard autocomplete format |
Content | Array of Content Item Objects | Array of content item objects with Value and url properties. |
Popular | Array of Popular Searches | Every popular search term object is an object with these two properties: |
SearchWebsiteUrl | Url | Base website url for clickable links. |
TrackingVersion | Alphanumeric text of size 2 | v1 or v2 based on your engine version |
KeywordField | Alphabetic | Parameter used to denote the keyword field |
CategoryHeading | Alphanumeric | Header text for Categories |
ContentHeading | Alphanumeric | Header text for Content Items |
ProductHeading | Alphanumeric | Header text for Products |
PopularHeading | Alphanumeric | Header text for Popular Searches |
ViewAllButtonLabel | Alphanumeric | Header text for “View All” link |
Example URLs for various environments as follows:
Environment | Environment URL |
---|---|
Dev | https://dev.hawksearch.net/sites/demo/?fn=ajax&f=GetSuggestions&q=coat&hawkoutput=json |
Test | https://test.hawksearch.net/sites/demo/?fn=ajax&f=GetSuggestions&q=coat&hawkoutput=json |
Production | https://lusearchapi-na.hawksearch.com/sites/demo/?fn=ajax&f=GetSuggestions&q=coat&hawkoutput=json Note: if you have been provided with a custom domain such as yoursite.hawksearch.com, please replace lusearchapi-na.hawksearch.com in the above url with your custom domain URL. |
...
HTTP/Keep-Alive
In the event that you see unexpected timeout errors from the site when testing, please confirm your http web request settings for the request you make to hawksearch. In some cases, the clients reset the connection instead of leaving it in Time_Wait/Close_Wait causing IIS to log it as an interruption. In this scenario please force the request to be Http 1.0 with no keep alive and see if timeouts no longer appear.
...
Info |
---|
NOTE: In order to populate data in the Hawksearch Reports, and to leverage Personalized Search, it is CRITICAL to implement Tracking Integration. |
Click here for instructions on adding Hawksearch Event Tracking Code .