4

I am trying to find a managed / crawled property in SP2013 O365 that will give me the actual "name" / site title of the Root Site Collection. I can get the URL using "SPSiteURL", but is there a correlating value that I can map to one of the refinablestrings?

I'd like to use it as a Refiner to locate specific sites across multiple site collections that a user has permission to view and haven't stumbled upon it.

4 Answers 4

8

As Vadim mentioned, you cannot create new managed properties in SPO with Refinable option enabled.

However, you can map the crawled property (ows_SiteName) to an already created Managed Property in SPO (RefinableString00) as shown in the below image:

enter image description here

You can then set an Alias (SiteTitle) to the RefinableString00 property and use it in search just like you would use a normal Managed Property.

Note that after you have done this mapping, it will take some time for the SPO search to crawl your newly mapped property so the results won't show up immediately.

3
  • +1 Great solution! Commented Mar 20, 2014 at 22:07
  • thanks, unfortunately that was not my question, i had previously done what you described, but i am looking to get the name of the top level site, so multiple sub sites would have the same root site collection Commented Mar 21, 2014 at 2:05
  • Any reason why you want to get the root level site name from search? You can easily get the value from a REST (or JSOM) call e.g. _api/Site/RootWeb/Title Commented Mar 21, 2014 at 6:31
2

There is a managed property named SiteTitle , but this property is not refinable and therefore it makes it impossible to use in Refinement web part.

enter image description here

From another hand, due to some limitations in SharePoint Online, you can't create a new managed property with Refinable option enabled.

0

I couldn't find the property either to use in a refinementpanel so I have used the SPSiteURL managed property to get the SiteCollectionUrl and show this. The SPSiteURL was not 'friendly' enough, because the view would be like:

https://myurl.com/... 
https://myurl.com/...

(URLS were too long)

With a custom display template I have mapped the URLs to friendly names. If an URL is not available in the mapping, it just shows the url instead.

SharePoint does this technique itself with the FileType Managed Property. So I just tweaked that one a bit.

Create a copy of the normal Refinement item Display template and remove the bits you don't need.

These are the interesting parts for the mapping:

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)];            
    }        
}   

Basically what it does is check if the propertyName is SPSiteURL:

if(ctx.RefinementControl.propertyName == "SPSiteURL")

then calls the function to map the friendlynames to the urls:

listData[i].RefinementName = mapSiteUrl(listData[i].RefinementName);

The mapping happens here:

map["MyFriendlyName1"] = {
        "RefinerName": "SPSiteURL",
        "RefinementValue": ["http://myurl.com"]
    };

Just copy and paste it to make more of these mappings.

Then, just pick your new Display Template as an option for the SPSiteURL Managed Property in the web part properties.

0

For the Root Site Collection, it's "SPSiteURL" SPWebURL is current site URL; SPSiteURL is root tite collection

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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