API: Customizing the order of search results

You can use Haiilo's API to change the order in which search results appear by content type in the global search. You need the "Manage global search" permission to customize the search settings.

To make calls to the Haiilo API, you need to authenticate first. You can find detailed information about authenticating and using the API here.

List all search settings

  1. Make a GET request to the endpoint /web/global-search/settings to get a list of all search settings

The response should look similar to below:

 {
    "settings": {
        "feedbackToolActivation": {
            "value": true,
            "stringValue": "true",
            "readOnly": true
        },
        "typeOrder": {
            "value": [
                "sharepoint",
                "drive",
                "file",
                "blog_article",
                "wiki_article",
                "user",
                "page",
                "comment",
                "timeline_item",
                "app",
                "workspace",
                "event",
                "forum",
                "list-entry",
                "message"
            ],
            "stringValue": "[sharepoint, drive, file, blog_article, wiki_article, user, page, comment, timeline_item, app, workspace, event, forum, list-entry, message]",
            "readOnly": false
        }
    }
}

Update the order of search results

  1. Copy the entire setting group starting from the first { to the last } for that group. E.g.,
    {
       "value": [
           "sharepoint",
           "drive",
           "file",
           "blog_article",
           "wiki_article",
           "user",
           "page",
           "comment",
           "timeline_item",
           "app",
           "workspace",
           "event",
           "forum",
           "list-entry",
           "message"
       ]
    }
  2. Enter the entire copied setting group in the request body. If you don't include all content types, the undefined types are displayed at the end of the search results in alphabetical order.
  3. Make the desired changes to the order of the search results by moving the values in the list. Setting groups marked with "readOnly": true cannot be changed. 
    • In our example, we are moving timeline posts, blog articles, and wiki articles to the top so that results from these types display first in the global search.
      {
         "value": [
             "timeline_item",
             "blog_article",
             "wiki_article",
             "sharepoint",
             "drive",
             "file",
             "user",
             "page",
             "comment",
             "app",
             "workspace",
             "event",
             "forum",
             "list-entry",
             "message"
         ]
      }
  4. Make a POST request to the endpoint /web/global-search/settings/<name_of_setting> where <name_of_setting> is the name of the setting group, e.g., typeOrder.

Was this article helpful?