Search This Blog

Thursday, March 6, 2014

Increase KQL query length limit in SharePoint 2013

The length limit of a KQL query varies depending on how you create it. If you create the KQL query by using the default SharePoint search front end, the length limit is 2,048 characters. However, KQL queries you create programmatically by using the Query object model have a default length limit of 4,096 characters. You can increase this limit up to 20,480 characters by using the MaxKeywordQueryTextLength property or the DiscoveryMaxKeywordQueryTextLength property (for eDiscovery).

Source - MSDN - Link 

Using PowerShell the length can increased.

Code snippet:

$SearchApplicationName = "Search Service Application";
$ServiceApplication = Get-SPEnterpriseSearchServiceApplication -Identity "Search Service Application";

$ServiceApplication.MaxKeywordQueryTextLength = 5000;

This will increase the KQL length to 5000.