SharePoint number fields and search

If you are having problems making searches with number fields then you have to add them to a managed property in the Search Schema in your Search Service. Make sure that you tap the check boxes that the property is searchable. Also, make sure that the managed property data type is set to text.


How to display all of the refinement options in SharePoint 2013 Search results

By default for some reason, I could not show all of the items, I could define how many items are shown and but not get rid of the “show more” links under the refinements.

This JavaScript snippet can help you. It will hide the “short list” containing a minimum of items to be displayed, then it will show the long list and finally it will hide the “show more” link.

 $( document ).ready(function() {


SharePoint Search and changing the Created and LastModified fields

If you want to change the LastModified and Created fields of a list item or a document you can use this code to do that:

using (SPSite site = new SPSite("site + web url"))
using (SPWeb web = site.OpenWeb())
web.AllowUnsafeUpdates = true;
SPListItem listItem = web.GetListItem(this.tbItemURL.Text);

if (this.cCreatedDate.SelectedDate != new DateTime())
listItem[SPBuiltInFieldId.Created] = this.cCreatedDate.SelectedDate;
listItem[SPBuiltInFieldId.Created] = listItem[SPBuiltInFieldId.Created];

if (this.cModifiedDate.SelectedDate != new DateTime())
listItem[SPBuiltInFieldId.Modified] = this.cModifiedDate.SelectedDate;
listItem[SPBuiltInFieldId.Modified] = listItem[SPBuiltInFieldId.Modified];

if (listItem.ParentList.EnableMinorVersions)
if (listItem.ModerationInformation != null)

web.AllowUnsafeUpdates = false;

The reason why the above is done is because if you simply change the date values and use the UpdateOverwireVersion() it will not be enough. The search will not be able to index right values EVEN if you check the UI or use PowerShell or SharePoint Manager etc. All of those show that the value is OK but actually is not. The manually inserted dates will not show up in search unless the item or document is published and approved. So no matter that SP says remember this :).

another thing is that this code above does not allow to set a LastModified IF you have publishing/versioning enabled. After calling the UpdateOverwriteVersion function the item or document will be checked out and remains in that state until something is done. Once you do that you are back to where you started the modified date is changed automatically by SP.

Do not have a solution yet. Maybe you have?

SharePoint Seach Query: Include or Exclude empty or null dates

This was a tricky one for me. I had to search and figure out by trial and error what works.

To filter out a datetime managed property you could use definition:


Notice the following important things:

  • the minus sign (-) => is to not include someting that is a certain definition
  • ExpirationTime => will be replaced with your managed property name
  • 1900-01-01..{Today} => is a range, the minimum value is the “empty” or “null” value in a SharePoint datetime field. In other words the lowest possible datetime value which is 1900-01-01.


To include “null” or “empty” date time values just remove the minus (-) sign

SharePoint 2013 Search and Search Index Problems

If you find yourself in a situation where your search does not work you have some options:

  1. Do a full crawl
  2. Reset the search index and Do a full crawl
  3. Maybe along the way restart the SharePoint search service and/or the SharePoint timer service
  4. And if none of the above then you have to get creative

In the third option usually you get errors on your search webpart or search results. These errors do not go away and nothing seem to help, like the option one and two above.

One of the last things which you can do before going crazy 🙂 would be to manually empty the configuration cache. You do this in the following way:

  1. Find the the folder named with a GUID which has cache.ini file under the C:\ProgramData\Microsoft\SharePoint\Config
  2. Stop SharePoint Server Search 15 and SharePoint Timer Services
  3. Backup the cache.ini file
  4. Delete all files except the cache.ini file
  5. Edit the cache.ini and make sure it has only 1
  6. Save and Close the file.
  7. Start SharePoint Server Search 15 and SharePoint Timer Services
  8. Start Index Reset from SharePoint Central Administration\Application Management\Manage Service Applications\SearchServiceApplication\Index Reset
  9. You will see your  C:\ProgramData\Microsoft\SharePoint\Config\YourGUID folder will be filled up new .xml files and your cache.ini file will be modified.
  10. Next I run a full search crawl to get some search results.

NOTICE: Do not do this if you are tight on time. Depending on the amount of data in your target environment running a full crawl will take a looon long time. All depends on the server resources and the amount of data in your target environment.

There is also a script from this at codeplex:

Hope this helps someone. I know I have spent enough time with this problem and it is anoying.


SharePoint Search Service Application Errors: The search application ‘Search Service Application’ on server did not finish loading. View the event logs on the affected server for more information

If you get this (annoying) error then a possible solution is to check if your account which you use to administrate(or use the search service application) on the SQL Server side.

The search application ‘Search Service Application’ on server did not finish loading. View the event logs on the affected server for more information

Open Your SQL Server Management studio. Go to your Security folder, then Logins and then double click on your account which needs search privileges. Then go to user mapping in the new window and check that the following search service databases has privileges to your account and that the account has the “SPSearchDBAdmin” rights assigned:

Search Databases:





Search Service Application Error

Search Service Application Error

SharePoint 2010 Full Text SQL Query – Ranged query results through Search Web Service

If you are wondering how to do a ranged search query through the SP search service pass to the query service something below where the ranged functionality is in the green color. Just specify the start position at the StartAt, notice that the minimum start position is number one not zero. Then you pass in the Count part how many items to retrieve starting from the specified location. To do a paging like functionality you have to keep count in you code what is your paging range, current position and what to retrieve.

<QueryPacket><Query domain=”QDomain”><Context><QueryText type=”MSSQLFT”><![CDATA[ SELECT your fields here FROM Scope() WHERE IsDocument = 1 AND “SCOPE” = ‘your scope name’ AND CONTAINS (some sample field,’field data to contain’) ORDER BY some field name]]></QueryText></Context><Range><StartAt>1</StartAt><Count>3</Count></Range><TrimDuplicates>false</TrimDuplicates></Query></QueryPacket>