Reputation: 391
I am setting the result source level to 'SPSite' as I want to use the result source defined at site collection level. But it does not work. Is 'SPSite' a valid argument in JSOM?
let query = new Search.KeywordQuery(ctx);
// set Source Name
query.get_properties().set_item('SourceName', 'Result Source Name');
// set Source Level
query.get_properties().set_item('SourceLevel', 'SPSite');
If I set the source level to 'SPSiteSubscription', it successfully use the tenant level result source.
Upvotes: 1
Views: 363
Reputation: 11
I was stumped at same spot for awhile. Adding a refiner filter to the query did the trick for me and the situation I was in. Might be useful to you as well.
// add refiner(s)
keywordQuery.set_refiners("SPSiteURL");
// add the returned columns
var properties = keywordQuery.get_selectProperties();
properties.add('SPWebUrl'); // site this comes from
// below is how to build the refinement filter to add to the keywordquery
var filterCollection = keywordQuery.get_refinementFilters();
// add scope filter, can be mannualy or can grab the webUrl from the client context
// var filter = Modifier + ':"' + RefinementToken(or value) + '"';
filterCollection.add('SPSiteURL:"'+webUrl+'"');
Upvotes: 1