No Results Search

Overview

In situations where the search keyword yields 0 results, the default search response will have empty “Results” object. You would still get the Pagination, Sorting, Redirect, Merchandising, Featured Items object if applicable.

Retrieving search with 0 results

{ "ClientGuid" : "SITE_GUID",  
  "Keyword" : "abcd123456",  
  "ClientData":{  
  "VisitorId" : "2F87556F-AA2F-438E-A52C-AFF4B7E10EB5",  
  "Custom" : {"some key" : "some value"},  
  "HttpTrueClientIp" : "some IP address",  
  "UserAgent" : "some agent",  
  "Source" : ""  
  }  
  }

Response

{  
    "Facets": \[],  
    "VisitorTargets": \[],  
    "TrackingId": "119dc96a-aa72-4747-b20a-903d62a447e8",  
    "Success": true,  
    "Pagination": {  
        "NofResults": 0,  
        "CurrentPage": 1,  
        "MaxPerPage": 12,  
        "NofPages": 0,  
        "Items": [  
            {  
                "Label": "12",  
                "PageSize": 12,  
                "Selected": true,  
                "Default": true  
            },  
            {  
                "Label": "20",  
                "PageSize": 20,  
                "Selected": false,  
                "Default": false  
            }  
        ],  
        "IsShowFirstLink": true,  
        "IsShowLastLink": true,  
        "NumberOfPageLinks": 4  
    },  
    "Keyword": "abcd123456",  
    "Results": \[],  
    "Selections": {},  
    "Sorting": {  
        "Items": [  
            {  
                "Label": "Product Name (A to Z)",  
                "Value": "nameasc",  
                "IsDefault": false,  
                "Selected": false  
            },  
            {  
                "Label": "Product Name (Z to A)",  
                "Value": "namedesc",  
                "IsDefault": false,  
                "Selected": false  
            }  
        ]  
    },  
    "QueryUsedAllKeywords": true,  
    "DocExplain": "",  
    "Redirect": {},  
    "Merchandising": {  
        "Items": \[  
            {  
                "Zone": "FeaturedLeftBottom",  
                "Title": "No Results Page - Popular Searches",  
                "ContentType": "widget",  
                "IsMobile": false,  
                "IsTrackingEnabled": false,  
                "MobileWidth": 0,  
                "MobileHeight": 0,  
                "Trigger": {  
                    "BannerGroupId": 123456,  
                    "Name": "Popular Searches",  
                    "SortOrder": 0,  
                    "Rule": {  
                        "RuleType": 0,  
                        "Field": "",  
                        "Condition": "",  
                        "Value": "",  
                        "FieldType": "System.String",  
                        "Guid": "12348df123456780accaec17d1071234",  
                        "ShouldEvaluateAfterSearch": false,  
                        "Operator": 0,  
                        "Rules": \[  
                            {  
                                "RuleType": 1,  
                                "Field": "nofresults:nofresults",  
                                "Condition": "equals",  
                                "Value": "0",  
                                "FieldType": "nofresults",  
                                "FieldName": "Number of Results",  
                                "FieldValue": "0",  
                                "Guid": "123456786285a64b0eaede45789jhjg42415",  
                                "ShouldEvaluateAfterSearch": false,  
                                "Operator": 2,  
                                "Rules": \[]  
                            }  
                        ]  
                    }  
                },  
                "BannerId": 0,  
                "CampaignId": 123456  
            }  
        ]  
    },  
    "FeaturedItems": {},  
    "SearchDuration": 15  
}

Use Hawksearch content item and campaign

🚧

Warning

This Content item gets created automatically when we set up the engine and it can be modified as per requirements.

If the customer types in a search word that does not yield any results, you have an opportunity to communicate with them by adding relevant text messages, targeted ads, banners, and widgets using Hawksearch dashboard.

Example use case: Display a custom text message for no results search page.

Step 1:

Set up a content item like below with the relevant text message.

Step 2

Set up a campaign that would define the trigger when the Content item created above should be returned in the response.

Steps to add a Campaign: Campaigns | Campaigns AddingaNewCampaign

Step 3:

Please confirm that the Content item is being returned in the response for no results page.

Request: POST request to search keyword “abcdefg”:

POST /api/v2/search HTTP/1.1  
Host: searchapi-dev.hawksearch.net  
Content-Type: application/json  
Cache-Control: no-cache  
Postman-Token: b1dc5ba6-9262-bc68-c48a-0a344afe5316

{  
  "index":"elasticdemo.20210325.082034",  
  "ClientGuid": "f12458r1c38446f0bacdf283390c37e8",  
  "keyword":"abcdefg"  
}

Response: In the search results response structure, there are 2 main keys which include the information about the Content item/Campaign created above:

  • “Output” is the HTML content created in step 1 above which can be rendered on-site end as is
  • “Trigger” indicates the Campaign information and the rule being used to insert the content item in the response.
"Merchandising": {  
        "Items": \[  
            {  
                "Zone": "Top",  
                "Title": "No Results",  
                "ContentType": "custom",  
                "ForwardUrl": "",  
                "Output": "<p>\<span style=\"background-color:#ffff00;\"></span></p>\<span style=\"font-size:14px;\"> - Please double check your spelling.</span>\<br style=\"font-size:14px;\" />\<span style=\"font-size:14px;\"> - Try searching for an item that is less specific.</span>\<br style=\"font-size:14px;\" />\<span style=\"font-size:14px;\"> - You can always narrow your search results later.</span>\<span style=\"background-color:#ffff00;\"><br /></span><p>\<span style=\"background-color:#ffff00;\"></span>\<span style=\"background-color:#ffff00;\"><br /></span><br /></p>",  
                "IsMobile": false,  
                "IsTrackingEnabled": false,  
                "Target": "",  
                "MobileWidth": 0,  
                "MobileHeight": 0,  
                "Trigger": {  
                    "BannerGroupId": 56308,  
                    "Name": "No result message ",  
                    "SortOrder": 0,  
                    "Rule": {  
                        "RuleType": 0,  
                        "Field": "",  
                        "Condition": "",  
                        "Value": "",  
                        "FieldType": "System.String",  
                        "Guid": "b50126cabd7a4d618cfda1c231f00a32",  
                        "ShouldEvaluateAfterSearch": false,  
                        "Operator": 0,  
                        "Rules": \[  
                            {  
                                "RuleType": 1,  
                                "Field": "nofresults:nofresults",  
                                "Condition": "equals",  
                                "Value": "0",  
                                "FieldType": "nofresults",  
                                "FieldName": "Number of Results",  
                                "FieldValue": "0",  
                                "Guid": "47e68cd2234b41548636b02b039b1f5f",  
                                "ShouldEvaluateAfterSearch": false,  
                                "Operator": 2,  
                                "Rules": \[]  
                            }  
                        ]  
                    }  
                },  
                "BannerId": 73460,  
                "CampaignId": 56308  
            }  
        ]  
    }

Use Hawksearch Popular searches and campaign

If the customer types in a search word that does not yield any results, you have an opportunity to communicate with them by adding relevant text messages, targeted ads, banners, and widgets using Hawksearch dashboard.

Example use case: Display Popular searches for no results search page.

Step 1:

Set up a content item like below by adding default Popular searches widget.

Steps to add a Content Item: Content Items | ContentItems AddingaContentItem

Step 2:

Set up a campaign that would define the trigger when the Content item created above should be returned in the response.

Steps to add a Campaign: Campaigns | Campaigns AddingaNewCampaign

Step 3:

Please confirm that the Popular searches Content item is being returned in the response for no results page.

Request: POST request to search keyword “abcdefg”:

POST /api/v2/search HTTP/1.1  
Host: searchapi-dev.hawksearch.net  
Content-Type: application/json  
Cache-Control: no-cache  
Postman-Token: b1dc5ba6-9262-bc68-c48a-0a344afe5316

{  
  "index":"elasticdemo.20210325.082034",  
  "ClientGuid": "f12458r1c38446f0bacdf283390c37e8",  
  "keyword":"abcdefg"  
}

Response: In the search results response structure, there are 2 main keys which include the information about the Content item/Campaign created above:

  • “Output” is the array of key-value pairs of top keywords and their count.
  • “Trigger” indicates the Campaign information and the rule being used to insert the content item in the response.
"Merchandising": {  
        "Items": \[  
            {  
                "Zone": "LeftBottom",  
                "Title": "Popular Tags",  
                "ContentType": "widget",  
                "Output": [  
                    {  
                        "keyword": "jacket",  
                        "count": 282  
                    },  
                    {  
                        "keyword": "red jacket",  
                        "count": 149  
                    },  
                    {  
                        "keyword": "print",  
                        "count": 83  
                    },  
                    {  
                        "keyword": "jackt",  
                        "count": 36  
                    }  
                ],  
                "IsMobile": false,  
                "IsTrackingEnabled": false,  
                "MobileWidth": 0,  
                "MobileHeight": 0,  
                "Trigger": {  
                    "BannerGroupId": 56254,  
                    "Name": "No Results Page - Popular Searches",  
                    "SortOrder": 0,  
                    "Rule": {  
                        "RuleType": 0,  
                        "Field": "",  
                        "Condition": "",  
                        "Value": "",  
                        "FieldType": "System.String",  
                        "Guid": "6121d5d07b6e46969c858e8bd7ca079c",  
                        "ShouldEvaluateAfterSearch": false,  
                        "Operator": 0,  
                        "Rules": \[  
                            {  
                                "RuleType": 1,  
                                "Field": "nofresults:nofresults",  
                                "Condition": "equals",  
                                "Value": "0",  
                                "FieldType": "nofresults",  
                                "FieldName": "Number of Results",  
                                "FieldValue": "0",  
                                "Guid": "d9e11cbb6d5d48f9add325e7bd93fc88",  
                                "ShouldEvaluateAfterSearch": false,  
                                "Operator": 2,  
                                "Rules": \[]  
                            }  
                        ]  
                    }  
                },  
                "BannerId": 0,  
                "CampaignId": 56254  
            }

Use Hawksearch Spotlights and campaign

If the customer types in a search word that does not yield any results, you have an opportunity to communicate with them by adding relevant text messages, targeted ads, banners, and widgets using Hawksearch dashboard.

Example use case: Display Popular Products for no results search page.

Step 1:

Set up a Spotlight item like below by adding items that you want to display on the no results page.

Steps to add a Spotlight Item: Product Spotlighting | ProductSpotlighting AddProductSpotlight

Step 2:

Set up a campaign that would define the trigger when the Spotlight created above should be returned in the response.

Steps to add a Campaign: Campaigns | Campaigns AddingaNewCampaign

Step 3:

Please confirm that the Popular searches Content item is being returned in the response for no results page.

Request: POST request to search keyword “abcdefg”:

POST /api/v2/search HTTP/1.1  
Host: searchapi-dev.hawksearch.net  
Content-Type: application/json  
Cache-Control: no-cache  
Postman-Token: b1dc5ba6-9262-bc68-c48a-0a344afe5316

{  
  "index":"elasticdemo.20210325.082034",  
  "ClientGuid": "f12458r1c38446f0bacdf283390c37e8",  
  "keyword":"abcdefg"  
}

Response: In the search results response structure, there are 2 main keys which include the information about the Spotlight/Campaign created above:

  • “Items” is the array of items to be displayed on the page
  • “Trigger” indicates the Campaign information and the rule being used to insert the content item in the response.
"Merchandising": {  
        "Items": \[  
             {  
                "Zone": "Top",  
                "Title": "Some items you may like",  
                "Name": "No results",  
                "ContentType": "featured",  
                "ForwardUrl": "",  
                "Output": "",  
                "WidgetArgs": "",  
                "IsMobile": false,  
                "IsTrackingEnabled": true,  
                "Items": \[  
                    {  
                        "DocId": "Item_74225",  
                        "Score": 93,  
                        "Document": {  
                            "brand": [  
                                "Columbia Sportswear"  
                            ],  
                            "image": [  
                                "https://dev.hawksearch.net/assets/1/14/DimThumbnail/Silver-Ridge-Plaid-LS-Shirt_Fossil-Dobby.jpg"  
                            ],  
                            "url": [  
                                "/details.aspx?itemid=Item_74225"  
                            ],  
                            "itemname": [  
                                "Men's Silver Ridge Plaid Long Sleeve"  
                            ],  
                            "rating": [  
                                "+0000000000000001.0000"  
                            ],  
                            "itemtypeid": [  
                                "3"  
                            ],  
                            "saleprice": [  
                                "+0000000000000047.9700"  
                            ],  
                            "createdate": [  
                                "2020-11-22T14:12:47"  
                            ],  
                            "type": [  
                                "Item"  
                            ],  
                            "ratingrange": [  
                                "+0000000000000001.0000"  
                            ],  
                            "content": [  
                                "men's silver ridge plaid long sleeve &#60;div class&#61;&#34;descwrpr&#34;&#62;&#60;div class&#61;&#34;descsubwrpr&#34;&#62;&#60;h2&#62;product description&#60;&#47;h2&#62;&#60;br&#62;&#60;p&#62;designed to keep you dry, protected and comfortable during long active days in the sun, this columbia classic features quick-wicking material, strategic venting, classic plaid prints and built-in upf 40 blocking power.&#38;nbsp&#59;&#60;&#47;p&#62;&#60;&#47;div&#62;&#60;&#47;div&#62;   men men shirts men shirts casual shirts travel travel clothing men's travel clothing specials sportswear mens specials sportswear mens shirts summer sale men summer sale men shirts summer sale men shirts casual shirts summer sale packs backpacking packs summer sale travel travel clothing men's travel clothing summer sale men shirts hiking/travel shirts men shirts hiking/travel shirts specials sat dec 15th kids long sleeve summer sale packs summer sale travel travel clothing summer sale travel deals for dad shirts specials sportswear sale specials summer sale deals for dad summer clearance columbia sportswear medium extra large purple blue green blue "  
                            ],  
                            "id": [  
                                "Item_74225"  
                            ],  
                            "price": [  
                                "+0000000000000060.0000"  
                            ],  
                            "department_nest": [  
                                "1|Summer Sale",  
                                "2|Summer Sale/Travel",  
                                "3|Summer Sale/Travel/Travel Clothing",  
                                "1|Specials",  
                                "2|Specials/Sat Dec 15th",  
                                "3|Specials/Sat Dec 15th/Kids",  
                                "1|Men",  
                                "2|Men/Shirts",  
                                "3|Men/Shirts/Hiking",  
                                "4|Men/Shirts/Hiking/Travel Shirts",  
                                "2|Summer Sale/Men",  
                                "3|Summer Sale/Men/Shirts",  
                                "2|Summer Sale/Packs",  
                                "3|Summer Sale/Packs/Backpacking Packs",  
                                "2|Specials/Sportswear",  
                                "3|Specials/Sportswear/Mens",  
                                "1|Travel",  
                                "2|Travel/Travel Clothing",  
                                "3|Travel/Travel Clothing/Men's Travel Clothing",  
                                "3|Men/Shirts/Casual Shirts"  
                            ],  
                            "imagealttag": [  
                                "Silver-Ridge-Plaid-LS-Shirt_Fossil-Dobby"  
                            ],  
                            "sku": [  
                                "\r\n    "  
                            ],  
                            "subdepartmentpath": [  
                                "1|Men",  
                                "1|Travel",  
                                "1|Specials",  
                                "1|Summer Sale",  
                                "1|Long Sleeve",  
                                "1|Deals for Dad",  
                                "1|Sale",  
                                "1|Summer Clearance"  
                            ]  
                        },  
                        "BestFragments": {  
                            "itemname": "Men's Silver Ridge Plaid Long Sleeve"  
                        },  
                        "IsPin": false,  
                        "IsVisible": true  
                    }  
                ],  
                "Target": "",  
                "MobileWidth": 0,  
                "MobileHeight": 0,  
                "Trigger": {  
                    "BannerGroupId": 56297,  
                    "Name": "No Results Test",  
                    "SortOrder": 0,  
                    "Rule": {  
                        "RuleType": 0,  
                        "Field": "",  
                        "Condition": "",  
                        "Value": "",  
                        "FieldType": "System.String",  
                        "Guid": "d9581b8790cd48e791b81fba670dd009",  
                        "ShouldEvaluateAfterSearch": false,  
                        "Operator": 0,  
                        "Rules": \[  
                            {  
                                "RuleType": 1,  
                                "Field": "nofresults:nofresults",  
                                "Condition": "equals or less than",  
                                "Value": "0",  
                                "FieldType": "nofresults",  
                                "FieldName": "Number of Results",  
                                "FieldValue": "0",  
                                "Guid": "0c03ad4d09e94b42929bffc15b86dc5a",  
                                "ShouldEvaluateAfterSearch": false,  
                                "Operator": 2,  
                                "Rules": \[]  
                            }  
                        ]  
                    }  
                },  
                "BannerId": 73531,  
                "CampaignId": 56297  
            }