0

I have a situation where I send a search query to get the titles of lists and document libraries using listID property. ListIDs are dynamically added which retrieved from another search. The issue is, when the listIDs go more than 77, i.e exceed the QueryText max length, search yield no results. I know we can increase the MaxKeywordQueryTextLength in On Premises SharePoint, but couldn't find a way to do it in SharePoint Online.

If this is possible, please share with me how to do it. Otherwise I have to go with my alternative as grouping ListIDs into a set contain 75 IDs each and send seperate search requsts each, then combine the results.

1

According to this page 4,096 characters is a hard boundary. I believe ou will need to split your search requests.

  • Yeah. That page came up in my earlier search. I just wanted to know if there are any workarounds or changes. Looks like I'll have to go with my alternative plan.. – anbuj Jul 20 '17 at 5:24
0

Answering my own question in case someone else has the same issue. I've split my list IDs array into a set of 75 IDs each, then send separate search requests for each set. The results returned was assigned to a promise array. Then, using $q.all I've resolved the results. Then the results are merged into a single array.

function GetListTitlesByID(links) {
// should be 75 or less as exceeding it exceed max query length
var queryLimit = 75;
// removing duplicates and adding ListID to a unique array
var uniqueList_1 = [];
var splitList = [];

links.forEach(function (item) {

    if (uniqueList_1.indexOf(item.ListID) === -1) {

        uniqueList_1.push(item.ListID);

    }
});

// splitting the listIDs into a set of 75 IDS
var i = 0;

for (i = 0; i < uniqueList_1.length; i += queryLimit) {

    splitList.push(uniqueList_1.slice(i, i + queryLimit));

}
// sending a title search for each set of IDs in splitList
var myPromises = [];
var myLists = [];

splitList.forEach(function (item) {

    // builds search query with list IDs
    var query = _this.buildTitleSearchQuery(item, titleQuery);

    myPromises.push(_this.dataService.Retrieve(query));

});

this.$q.all(myPromises)
.then((res) => {

    res.forEach((x) => {

        myLists = myLists.concat(x);

    });

    var combinedLinks = this.GetCombinedResults(links, myLists, queryInfo);
    defer.resolve(combinedLinks);
});

}

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.