Result Groups

What is the result group feature and how do I use it?

This article explains the importance of result groups and shows a way to implement the result group feature in SS360.

Websites often separate content into categories. Take for example the news website today.com. In the above screenshot you can see their category navigation, which groups all their articles into categories like videos, food, or health & wellness.

If you group your content into categories of course you want to have them mapped to your search engine. Result Grouping is a quick way to divide your search results into large categories, e.g. Products, News, PDFs, Reviews. We usually recommend using no more than 5-7 groups. For more facets, you might want to implement Filters instead.

If a user searches for the term "Jimmy Fallon" on today.com, SS360 would deliver all hits within all categories in one big list. But what if the user is only interested in videos with "Jimmy Fallon" out of the "video" category or if he wants to see the cooking tips out of the "food" category?

To solve this issue, you can define result groups for the SS360 search engine. This way it is possible to generate categories that may be clicked to reduce the huge list of initial results to a subset of hits within the chosen category.

Check out our demo site examples to see result groups in action.

How do I set up Result Groups?

You will find all settings related to Result Groups in the control panel under "Data Structuring > Result Grouping".

Press the "Add result group" button to open the pop-up Result Group creation menu:

The menu lets you define all the settings needed to get the Result Group up and running.

Let's take a look at each setting in detail.

  1. Name of the Result Group - this will be the title of the Result Group visible for your search users. It's best to keep it short and simple.

  2. Show this result group in search results switch - turn it on to show the Result Group in the results. You can turn it off if the Result Group is meant to be used only in suggestions.

  3. Show this result group in search suggestions switch - turn it on to show the Result Group in the suggestions (the preview of the search results displayed when you type your search query). You can turn it off if the Result Group is meant to be used only in results.

  4. A maximum number of items to show in suggestions - define how many items from this Result Group will be displayed in the preview of the search results displayed when the user is typing his search query.
    You can limit this number to avoid getting too many results from one Result Group in suggestions.

  5. URL Pattern/XPath selector - decide how do you want to define which pages will be included in your Result Group.
    Remember that each page can be included in only one Result Group at a time!

  6. URL Pattern/XPath input
    Here you can tell the system how to recognize a result group on your site. The input type depends on the selection made with the selector described above.

    6.1 URL pattern (regular expression): If you navigate on today.com to the food category the URL changes and may look like "https://www.today.com/food/feel-better-foods-tips-recipes-dr-oz-t116700". The indicator for the food category is the /food/ element in the URL. This way we will catch all the URLs with /food/ - so this is the value that should be used in this input.
    Another example: when you click the navigation point "Health & Wellness" the URL changes to "https://www.today.com/health/cvs-limit-opioid-prescriptions-7-day-supply-t116587", so for this result group the indicator would be /health/. 1

    Another common example would be \.pdf, if you want to group all your PDF files.
    If you want to catch multiple URL patterns just use a pipe separator |. For example, /food/|/health/ would catch both URLs and put them in the same result group.

    6.2 XPath: If your URLs don't indicate the category you want to make into a result group, you may use the XPath feature. Here you can point to a unique DOM element that is only available on pages that should go into this result group.
    Coming back to our today.com example, we can check the source code for unique elements within a page in the "Health&Wellness" category. Near the headline of each article in this category, you find a link to the category overview page, which could serve as an indicator for this result group.

    A valid XPath expression to find this indicator would be //div[contains(@class, 'articleTitleSection')]//span[contains(text(),'Health & Wellness')]
    Only the existence of this indicator will classify this page as part of the result group "Health & Wellness"

    You can learn more about XPaths in our docs -> Working with XPaths

  7. Override options - 4 buttons at the bottom of the window can help you with fine-tuning the content extraction for your new Result Group. You can define the group-specific title, image and content inclusion/exclusion rules.
    More about content extraction can be found in this article.

After you have defined your Result Group click on "Add" and then "Save". Your changes will be visible after the next site reindexing.

Once it's done you can check your results in the Search Preview tab:

You may style the Result Groups buttons any way you want, it is fully customizable via CSS.

Result groups (except the All results view) are mutually exclusive, i.e. if a page or a document is assigned to a group, it can't belong to any other group. If a page does not match any of your groups, it is put in the "Other" (=uncategorized results) category.

Using the API

If you want full control over your search and the search result page you may use the SS360's HTTP REST API to add content to your index. It's possible to set the appropriate Result Group for each page you index directly in the JSON object you send to the API.

Note: starting version 13 of our search script, we display result groups as tabs by default, with the first tab showing All Results that combine matches from all other groups. The related settings can be found and adjusted on the Installation page or under the layout.navigation parameters:

var ss360Config = {
    layout: {
        navigation: {
            position: 'top', /
 can also be 'left' 
/ 
            type: 'tabs', /
 can also be 'scroll' 
/
            showAllResultsTab: true,
            allResultsTabName: 'All Results',
            allResultsTabTitle: 'Found #COUNT# results for \'#QUERY#\'' /
 e.g. 'Found 43 results for "curry"' 
/
        }
    }
}

For more configuration options, check this list of possible parameters.

How do I show or hide specific result groups?

Sometimes you need to limit your search results to a particular result group, which can be done with the include or exclude parameters (either one is enough to get the job done). For example, you want to show Products and Reviews and ignore all other results. There are two ways of setting this up:

  • You can adjust your ss360Config code like this:

var ss360Config = {
    contentGroups: {
        include: ['Products','Reviews']
    }
}
  • You can add data-ss360-include or data-ss360-exclude attributes to your search box HTML markup:

<input type="search" data-ss360-include="['Products','Reviews']">
  • If you are using our WordPress search plugin and you are not sure how to access or edit your search input HTML markup, you can add a new search box with shortcodes and apply the limitation here instead:

[ss360-form][ss360-searchbox include="'Products','Reviews'"][ss360-searchbutton][/ss360-searchbutton][/ss360-form]

This is especially useful if you have multiple search boxes and you want to restrict one of them to search a specific area of your site (here's an example).

The data-ss360-include and data-ss360-exclude attributes apply both to search results and search suggestions.

If you want to show different groups in the suggestion dropdown, you can apply data-ss360-include-suggestion and data-ss360-exclude-suggestion attributes respectively. To include all possible results and suggestions, leave it empty: data-ss360-include="[]".

Note: when there are several groups to include or exclude, make sure they are formatted as a JSON Array, separated by a comma, e.g. ['Group 1', 'Group 2', 'Group 3']. The group names should match the names given in the Result Grouping section.