Support Article

Custom sorting on Knowledge Management(KM) Search

SA-37168

Summary



When the user search in Knowledge Management portal with some specific key words Knowledge contents are shown in the search results. However these search results not arranged in an orderly fashion. The search result set comprise of a set of contents which have the search keyword either in their title , article content or in the associated tags. The user wants the contents fetched should be sorted in a way where the contents(articles) with the search keyword in their title will appear first. The KC items returned as serach results are required, shown below :

  1. Title first
  2. Content
  3. Tags



Error Messages


Not Applicable


Steps to Reproduce

  1. Create some Knowlege Contents and publish them from the Knowledge Management portal
  2. The CPM interaction portal.
  3. Click the help icon.
  4. In the pop up window search with a Keyword.
  5. Check the sorting of the Knowledge contents returned as search results.


Root Cause



Tracing down the activity stack shows that the results(KC items) are fetched using the elastic search(ES).
Thus ES will not return the result by grouping them with the article title , then the article content and so on.
Also a seperate search is made to find KC objects which have the search keyword present in their tags.
Thus the final search result is a mixture of all the objects with out any orderly fashion of arrangment.

Resolution



This can be achieved through a custom logic in theRULE-OBJ-ACTIVITY @baseclass.KMSearchRD activity rule. This is a Pega OOTB activity which is available for cuistomization.
The following approach can be taken :-

  1. Scan through the full resultset
  2. Copy the rows which contains the keyword in their title.
  3. Next, append the remaining rows which do not contain the search keyword in their title.
  4. The final page (pySearchResultsFiltered in this case) will have the sorted results.

A custom solution looks like this :-


Evaluate Expression [@String.contains(.ArticleTitle,param.searchText)]

pxResults(1) True Page-Copy Temp. pxResults(<APPEND)>) Temp. pxResults(1)
pxResults(2) False Temp. pxResults(2)
pxResults(3) True Page-Copy Temp. pxResults(<APPEND)>) Temp. pxResults(3)
pxResults(4) True Page-Copy Temp. pxResults(<APPEND)>) Temp. pxResults(4)
pxResults(5) False Temp. pxResults(5)

Changes in the @baseclass.KMSearchRD activity :-

In the below screenshot Step no 14 , 15 , 16 and 18 are introduced for this custom solution.










The results are after applying the above changes :-




Published April 27, 2017 - Updated May 5, 2017

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.