Full Text Searches in Service Portal

screen-shot-2017-06-27-at-5-14-23-pm

In the stock Service Portal it asks the user “How can we help” and then provides the user with a big search input. This implies that the user could enter a sentence or phrase such as “reset my password” to answer the question, however this will rarely deliver the correct results.

ServiceNow provides several search operators for performing full text searches with GlideRecord using ServiceNow’s Zing search engine. However the stock widgets in Service Portal are hardcoded to use 123TEXTQUERY321” which works great for single word searches but not so much for searches containing multiple words or phrases. In this example, the simple addition of the word “my” prevented the user from finding the “Reset Password” item.

To improve the search results, let’s take a quick look at some of the other options available.

Search Operator Description
IR_AND_QUERY Display results with exact matches of all terms only (Same as 123TEXTQUERY321)
IR_OR_QUERY Display results with any matches of any terms.
IR_AND_OR_QUERY First display results with exact matches of all terms, then display results with any matches of any terms

Of the above, I recommend using IR_AND_OR_QUERY as this will return the best results across all combinations of searches. When performing a full text search, ServiceNow also adds an additional property to the GlideRecord called “ir_query_score” which contains the relevance score calculated by the system. Administrators can control the scoring for each field in a table with the ts_weight attribute.

Here is a quick example of how to search the Service Catalog and return results ordered by relevancy:

For further reading, check out:

https://codecreative.io/servicenow/gliderecord-full-text-search-explained
https://codecreative.io/servicenow/how-to-do-full-text-search-with-gliderecord
http://wiki.servicenow.com/index.php?title=Administering_Zing_Text_Search

 

9 comments

  1. Thanks Nathan Does this still leverage the existing text indexes that Zing search relies on? It’s just changing the operator, yes?

    1. Hadyn, yes exactly. It’s still using Zing and the text indexes, it’s just using a different operator which greatly improves the search results.

    1. As mentioned above, all the OOB widgets use “123TEXTQUERY321” which does not search multiple words or phrases very well. Contextual search is a completely different widget, and will not be fully supported until Jakarta.

  2. Hello Nathan,

    Is there a way to make the “typeahead” work with multiple catalogs and knowledge bases? I know there a few examples in share but they only work once you click enter on the search page. I want to show either catalogs or documents on the typeahead while am writing something. Am on Helsinki. Anything would be appreciated.

    1. Istanbul certainly simplifies this for you with Search Sources, however for Helsinki I would just recommend cloning and modifying the Typeahead widget. It’s just using GlideRecord so it should not be too difficult.

    1. In Helsinki it’s hard coded in to the widgets, in Istanbul it’s in the Search Sources. If you need additional help, feel free to email me.

Leave a Reply

Your email address will not be published. Required fields are marked *