Couldn't figure it out, and since I'm returning a list of node, I just do a LINQ search before returning the list.
result = from nodes in from searchResult in searchResults orderby searchResult.Score descending select new Node(searchResult.Id) where nodes.CreateDate.Date >= fromDate.Date where nodes.CreateDate.Date <= toDate.Date select nodes;
I have had this issue before the range method when translated to a lucene query converts the format of your date to 20111117122022 the date stored in lucene is in as 2011-11-17T12:20:22 so what I have done is implemented gatheringnode method and inject date in to new field in same format and then queried on that field works a treat.
Only issue you will have is if you need to display the create date on front end in your search results eg you want to display date dd/MM/yyyy if you try to parse that date you will get incorrect date becuase the format does not have - or / or : to separate out the different elements. However if you dont want to display the create date then its all good.
Examine range createDate
Hey Umbraco People
I've been struggling with some range-search on createDate.
And with this search
Where fromDate and toDate is two DateTime values.
It loos like the date is indexed, and it is probaly "just" some formatting issues.
But I'm nt sure how to fix it
Couldn't figure it out, and since I'm returning a list of node, I just do a LINQ search before returning the list.
A former collegue of mine, just pointed out the obvious fail, in my above date-filtering.
When the imagelibrary reaches a couple of thousands entrys, which it will, i might have to run the LINQ filtering an a couple of hundred nodes.
It would be much faster, if I could do the filtering in the searchquery instead. Whichs bring me back to my original question.
Anyone with a helping hand ?
kristofer,
I have had this issue before the range method when translated to a lucene query converts the format of your date to 20111117122022 the date stored in lucene is in as 2011-11-17T12:20:22 so what I have done is implemented gatheringnode method and inject date in to new field in same format and then queried on that field works a treat.
Regards
Ismail
Oh darn...
So your suggestion is that I implement gatheringnode method, and inject a date into a new field ind the below format
And then I do my range on that field, instead of the createDate standard field.
Kristoffer,
Exactly!
Regards
Ismail
Since my createDate is ONLY used for this search, I've just edited the createDate content, before inserting it
Works like a charm
Kristoffer,
Only issue you will have is if you need to display the create date on front end in your search results eg you want to display date dd/MM/yyyy if you try to parse that date you will get incorrect date becuase the format does not have - or / or : to separate out the different elements. However if you dont want to display the create date then its all good.
Regards
Ismail
I've thought of that, but all I use the createDate for, in this solution, is in the searchfiltering.
So for the time being, it works as it should.... And I've gained alot more knowledgee.... win-win :-)
By the way - if someone needs hours and minutes the dateformat has to be: "yyyyMMddHHmm00000"
KR
Dirk
is working on a reply...