SharePoint 2013 Search CSOM default row limit

Could be an interesting hint for those using CSOM search API: why are some of the results not returned?

Is it trim duplicates setting? No.
Is it some wildcard settings of the result source? No.

If you do not set the row limit of the query, you will get by default only 50 items. However, you can increase it like that:

var query = new Microsoft.SharePoint.Client.Search.Query.KeywordQuery(searchContext);
query.set_queryText('*');
query.set_trimDuplicates(false);
query.set_rowLimit(500);

Last line does the trick. Please note that – by default – 500 is the maximum value.

If you need to increase it, you can do it e.g. via Powershell for the entire search service application:

PS> $mySearchServiceApp = Get-SPEnterpriseSearchServiceApplication
PS> $mySearchServiceApp.MaxRowLimit = 2000
PS> $mySearchServiceApp.Update()
PS> iisreset

Hope it helps,
Lukasz

SharePoint 2013 Content Editor – zero width space characters

Sometimes, the content editor web part of SharePoint 2013 adds unwanted characters to the text within it. You check once, twice, remove any unnecessary line breaks, spaces etc., but after saving or in the HTML source of the page you find these weird characters: ​ – the zero width spaces (& #8203;)

They can mess up your CSS layout, and frankly, I have not found a solution to force SharePoint not to insert them.

One possible workaround would be to remove them with a library like jQuery, e.g.

[javascript]

$(’.ms-rtestate-field’).each(function(index,element)  {
var theeditor = $(element);
$(theeditor).html($(theeditor).html().replace(/u200B/g,”));
});
[/javascript]

The selector applies to the content editor webpart of SP2013.

Hope this helps.
Łukasz

SharePoint 2013: Get item order ID in the search results display template

In SharePoint 2013, when creating a custom display template for an item, sometimes you need to know, which item in the whole search results list it is. In other words, you need the information of which item in the whole sequence that is, and perform your own logic according to the parameter.

I’ve looked for the property quite a while, but finally found it. It is called piSearchResultId.

Practically you can call it like that in your display template:

ctx.CurrentItem.piSearchResultId

It’s value is similar to the following:

0_1 for first item in the list
1_1 for the second item
2_1 for the third item
…and so forth.

With such values you can extract the first number, and there you go!

Hope this helps,
Lukasz