Related KBs Extension

IT MonkeyIT Monkey O.G.
edited August 2016 in Cireson Uploads
This custom extension will perform a weighted search against the KB search portal API and then perform a relevance analysis against the IR/SR/CR and return the top 5 most relevent results and create both a notification at the top for the most relevent and a list on the right for the top 5 for easy access to relevent KBs

Requirements:
v5+ of the Cireson Portal

Installation:
Add the following lines to your custom.js file located in the CustomSpace folder of the Cireson Portal website directory:

/* Incident Tasks */
		app.custom.formTasks.add('Incident', null, function(formObj, viewModel){  	
			formObj.boundReady( function () {

				getRelatedKBs();

			});	
		});

/* Service Request Tasks */
		app.custom.formTasks.add('ServiceRequest', null, function(formObj, viewModel){  	
			formObj.boundReady( function () {

				getRelatedKBs();
		
			});
		}); 

/* Change Request Tasks */
		app.custom.formTasks.add('ChangeRequest', null, function(formObj, viewModel){  		
			formObj.boundReady( function () {

				getRelatedKBs();

			});
		});

Below this code in the custom.js file, you will need to paste the contents of the ext_RelatedKBs.js
Save your custom.js and then refresh your browser

Configuration:
None required.

Comments

  • Michael_BaldryMichael_Baldry Customer Adept IT Monkey ✭✭
    Quick note on this. We had this extension enabled for a few months, but it stopped working around the time that we installed V5 of the portal into our environment, so we disabled it. I finally had a chance to look at it, and found that it was throwing a 404 error saying that no resource was found that matches the request URI "http://<servername>/api/V3/KnowledgeBase/GetHTMLArticlesFullTextSearch?userId=<userid>&searchValue=<searchstring>&isManager=false" (with proper variables in place of the items enclosed in '<>'). I looked at the API and found that "userLanguageCode" is a required parameter; did that change in one of the more recent releases?

    In any case, switching the data object in the ajax call to include the 'userLanguageCode' has fixed this up for us. Just posting in case anyone else was running into the same problem.

    Code that wasn't working (starts at line 25 in the "ext_RelatedKB.js" file from the original post):
    "$.ajax({
    url: "/api/V3/KnowledgeBase/GetHTMLArticlesFullTextSearch",
    async: true, //this is the default but showing that it can be turned off
    data: {
    userId: session.user.Id,
    searchValue: searchString,
    isManager: false
    },
    type: "GET",
    ..."

    Working code:
    "$.ajax({
    url: "/api/V3/KnowledgeBase/GetHTMLArticlesFullTextSearch",
    async: true, //this is the default but showing that it can be turned off
    data: {
    userId: session.user.Id,
    searchValue: searchString,
    isManager: false,
    userLanguageCode: 'enu'
    },
    type: "GET",
    ..."
  • Adrian_PaechAdrian_Paech Customer Advanced IT Monkey ✭✭✭
    edited June 2016

    Love this extension! :)
    just a minor logic error in the code regarding calculation of relevance.

            for (var j = 0; j < titleArray.length; j++) {
             var occured = occurrences(data[i].Title, titleArray[j])
             relevence += occured;
            }

    should be:

            for (var j = 0; j < titleArray.length; j++) {
             var occured = occurrences(data[i].Title.toLowerCase(), titleArray[j])
             relevence += occured;
            }

    ..as the occurrences function was not ordering relevance correctly when there was a difference in case sensitivity. (e.g.: 'SharePoint' would not match 'sharepoint'). The above change fixes this.
    Cheers,

    Adrian

  • Adrian_PaechAdrian_Paech Customer Advanced IT Monkey ✭✭✭
     $.ajax({
      url: "/api/V3/Article",
      async: true,
      data: {
       searchValue: searchString      
      },
      type: "GET",
      success: function (data) {

    So, I have been trying to write some improvements for this add-on, but have found something strange with my  ajax api search results.

    Essentially, what I am trying to do, is pull back the "key words" for different search results, and using the keywords, sort kb articles by relevance, rather than using the title of the article instead (which is less accurate).

    Unfortionately, when using "/api/V3/KnowledgeBase/GetHTMLArticlesFullTextSearch" or "/api/V3/Article", it only seems to pull the "Title" and "Abstract" fields from KB articles, rather than other useful fields such as the "Keywords" field. The other fields are listed, but they are all null.

    I am running Portal version 5.0.7

    Any thoughts on this would be appreciated.

    Kind Regards,

    Adrian

  • seth_coussensseth_coussens Product Owner Ninja IT Monkey ✭✭✭✭
    In v5 we changed the API so this will no longer work without a few changes. I'll see if I can't get those pushed in this week.
  • Adrian_PaechAdrian_Paech Customer Advanced IT Monkey ✭✭✭

    Sounds great!

    Thanks Seth

  • seth_coussensseth_coussens Product Owner Ninja IT Monkey ✭✭✭✭
    Updated to v1.0.3. 
    - Resolved issues with it throwing an error in a new item template when the title and description were both empty
    - Resolved an issue where even if they were both filled in it would still choke on an output string
  • Marek_LefekMarek_Lefek Customer Advanced IT Monkey ✭✭✭
    Hu, does it still works. I try to implement in newest version but don't works. It looks that use depreciated ws command but after change to url: "api/V3/Article/FullTextSearch?searchValue={searchValue}", still nothing. Any idea?
Sign In or Register to comment.