0

I am showing data from 30+ different SharePoint sites. In the search results page i want to filter the result on the basis of Site Name or Site Title. However in O365 we do not have option filter on the basis of SiteTitle as it is not a refinable property. Instead we can refine on the basis of SPSiteURL. However the urls can be very lengthy and it will be very difficult for the users to filter on the basis of URL. I tried to Map the RefinementValue with a friendly name like it is shown below.

function mapSiteUrl(refinementName) {
    var map = {};
    map["MySiteName"] = {
        "RefinerName": "SPSiteURL",
        "RefinementValue": "http://MySiteUrl"
    };
    map["MySiteName2"] = {
        "RefinerName": "SPSiteURL",
        "RefinementValue": "http://MySiteUrl2"
    };
    map["MySiteName3"] = {
        "RefinerName": "SPSiteURL",
        "RefinementValue": "http://MySiteUrl3"
    };         

    var mappedRefinementName = null;

    for (var key in map) {
        if (refinementName.toLowerCase() === map[key].RefinementValue.toLowerCase()) {
            mappedRefinementName = key;
            break;
        }
    }
    if ($isNull(mappedRefinementName)) {
        mappedRefinementName = refinementName;
    }
    return mappedRefinementName;
}

var listData = ctx.ListData;
var hasControl = true;
var shortListSize = 5;

if ($isNull(ctx.RefinementControl) || $isNull(ctx.ClientControl)) hasControl = false;

if (ctx.RefinementControl.propertyName == "SPSiteURL") {
    shortListSize = 6;

    for (var i in listData) {
        listData[i].RefinementTokens = [listData[i].RefinementToken];
        listData[i].RefinementName = mapSiteUrl(listData[i].RefinementName);
        listData[i].RefinementTokenWrappedValues = [Srch.RefinementUtil.stringValueToEqualsToken(listData[i].RefinementValue)];            
    }        
}

However I do not want to hard code the URL in the refinment template. Instead I want to read it from a list which has list of URLs and the corresponding Site Title. I want to read the value from the list and then update the mapping in the refinement template. Please do let me know if there is any way I can accomplish this and filter the search results based upon site Title.

0

Navigate to the admin center -> Search -> Search Schema. Assign the crawled property ows_SiteName to one of the available refinable managed properties (like refinablestring00). Then configure the refiner webpart to show the managed property you have just configured. Refer to this link for screenshots. Although this article talks about SharePoint 2013 the approach should remain the same.

  • I have already tried this. But somehow the refinablestring00 does not shows up the Site title in the refiners section. Although while adding refiners when I preview I can see the filter data based on Site Name but when I save the page it does not show up anything. – Utkarsh Sep 11 '18 at 7:01
  • The property may not show up data immediately. Let the search crawl run and try again later. – sssreddy Sep 11 '18 at 15:36
  • I had mapped this property somewhere around last week but still cannot see the refiners based on that. – Utkarsh Sep 12 '18 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.