Thursday, April 14, 2011

DateTime resolution for querying FAST for SharePoint

I was doing range queries in the Search Center UI to limit documents between two exact dates.
image
But no matter what I entered as hours/minutes/seconds in my query I still got the same result.


There are good and bad news around this. The good news is that you can use the development api's to search with second resolution.

The bad news is that the Search Center UI disregards this, and when monitoring the queries received by FAST all hours/minutes/seconds are stripped from the query. They are adjusted for time zones as you can see below where 00:00:00 is turned into 23:00:00 of the day before the original query.
image

So if you want to do date range queries on an interval less than a day you have to use the development apis’s, and not the default Search page or query string.

9 comments:

  1. Since this is a problem, there would be some some solution for it. Can we configure Search Box web part properties in some way to achieve this ?

    ReplyDelete
  2. Raheem, I will investigate this further and see if I can find out where the stripping of the hours/minutes happens.

    ReplyDelete
  3. Ok, I have tracked this down to the SharePoint query parser inside of FAST. If you want it to work: you have to override the coreresults webpart, parse the query and rewrite it to FQL, submit the query via code/API instead of the QueryManager (unless you use reflection to enable FQL in the webpart).

    Either way, there is no quick fix.

    ReplyDelete
  4. Well, thanks Mikael for giving time to this investigation. Intercepting every query and rewriting it into FQL is not a clever solution :)

    ReplyDelete
  5. Hello, I am trying to get back the "Write" property values from FAST, but when I parse the resulting xml response, I find that the hours, minutes and seconds of the "Write" property are being disregarded.. For the "Created" property however this doesn't happen, I get the DateTime value exactly as in the FAST index (WITH hours, mins and seconds). In the index they are stored in almost the same format, so I wonder why only the "Write" property gets its hours, mins and seconds disregarded.. I am using the querymanager to issue the queries from my code directly, would it still help to rewrite the query to FQL then? And is there a quick way/method to turn an existing query into FQL? I have enabled FQL in my custom version of the CoreResultsWebPart.
    any help would be really appreciated!

    ReplyDelete
  6. Roel,
    nice find and a very good observation indeed. It will not help to use FQL in order to get hours and minutes, as FQL er for the queries going in, and will not change the format of what comes out.

    I see on some sample result xml's I have that hours etc is not being returned, but I'm not on my dev machine at the moment. I will explorer this further and get back to you.

    ReplyDelete
  7. Roel, I found out why and will create a post on it.

    ReplyDelete
  8. great, I'm looking forward to it! Will be checking your blog for this and other posts, because I've found some great practical pointers here already.
    Is there a workaround available? I'll just have to wait for your new post and see!

    ReplyDelete
  9. It's up at http://techmikael.blogspot.com/2011/06/datetime-resolution-on-your-sharepoint.html

    ReplyDelete