Search code examples
sharepoint-2013sharepoint-search

SharePoint 2013 Date Search inconsistent behavior between ?k=LastModifiedTime>4/28/2016 and ?#k=LastModifiedTime>4/28/2016


I'm doing some investigation on weird date search behaviour, the site has regional settings in NZ date format. When searching from the basic search page, this is the decoded version of the appended query string to the search results URL - ?k=DateCompleted=6/24/2004. This returns result with DateCompleted of 6/24/2004.

However clicking on the search again from the search Results page will return results with DateCompleted of 6/25/2004. 6/25 seems to be the NZT date conversion of the UTC 6/24. The query string of the URL is updated to - k=DateCompleted=6/24/2004#k=DateCompleted=6/24/2004

The difference is on the extra #k=DateCompleted=6/24/2004. Any idea on why there's a difference between ?k and #k for date search? My guess is it has something to do with the Ajax call but can't find any relevant information in technet/msdn/google searches.


Solution

  • Search result web part has a property AsynchronousResultRetrieval. Setting this to false will return results in local date (provided that the URL do not contain #k={search query}), but this setting breaks pagination because clicking the next page link will append the #k={search query} on the URL. When set to true, search treats the date search query consistently as UTC date, so searching for 6/24/2004 (UTC) will return results 6/25/2004 (local NZ time).

    Another property to be aware of is the IgnoreStaleServerQuery set this to true to get consistent results.