I've added a custom fieled called "__luceneFriendlyStartDate" which is basically StartDate in a yyyyMMddHHmmssnnn format (as per the various bits of documentation around the web).
When I run a search however the filter doesn't get applied, I've checked the data using Ismail's great extension and it shows that the fields are populated but this query returns no results:
__luceneFriendlyStartDate:[20131023000000000 TO 21131023000000000]
Do I need to create the field in a special way or am I missing something more fundemental?
Ok it looks to me as though you are not formatting your dates when doing the search. So do DateTime.Today.ToString("yyyyMMddHHmmss", CultureInfo.InvariantCulture)
Same thing for the other date. Also can you write out the actual generated query.
Open examine inspector do a search for any document that has the date field. Then click on the result it should open up a popup that will show you how all fields are indexed. Can you show how that date field is stored e.g I - Indexed; T - Tokenized; S - Stored, V - Term Vector also when you injected the field in did you do it using gatheringnode data event?
can u ping me on skype and screen share. also me and warren tried to contact you for uhangout we wnated to solve your issue with live coding session but he couldnt get hold of you.
Lucene not filtering on date range
I've added a custom fieled called "__luceneFriendlyStartDate" which is basically StartDate in a yyyyMMddHHmmssnnn format (as per the various bits of documentation around the web).
When I run a search however the filter doesn't get applied, I've checked the data using Ismail's great extension and it shows that the fields are populated but this query returns no results:
__luceneFriendlyStartDate:[20131023000000000 TO 21131023000000000]
Do I need to create the field in a special way or am I missing something more fundemental?
Cheers,
Tim
Tim,
When you check using examine inspector what do you see e.g I - Indexed; T - Tokenized; S - Stored, V - Term Vector?
Also the second value 21131023000000000 did you put that into the distant future? Also can you show me the c# code for the search.
Regards
Ismail
>When you check using examine inspector what do you see
Where am I looking for that? Had a click around but couldn't see anything.
>Also the second value 21131023000000000 did you put that into the distant future
Yes, we want all dates from today...
>Also can you show me the c# code for the search
Sure, although not all of it is relevant (I've been using the search in the inspector to test):
var query = criteria
.Field("umbracoNaviHide", "0")
.And().Field("nodeTypeAlias", "CourseVariation")
.And().Range("__luceneFriendlyStartDate", DateTime.Today, DateTime.Today.AddYears(100), true, true)
.And().GroupedOr(new[] { "__luceneFriendlyPath", "__NodeId" }, new[] { currentPageId });
Tim,
Ok it looks to me as though you are not formatting your dates when doing the search. So do DateTime.Today.ToString("yyyyMMddHHmmss", CultureInfo.InvariantCulture)
Same thing for the other date. Also can you write out the actual generated query.
Regards
Ismail
You're right, I'm not formatting them but I'm using the Range filter which does. This is what the query looks like in it's entirety:
{ SearchIndexType: , LuceneQuery: umbracoNaviHide:0 +nodeTypeAlias:coursevariation __luceneFriendlyStartDate:[20131023000000000 TO 21131023000000000] +(__luceneFriendlyPath:2916 __NodeId:2916) }
So I'm not sure why converting it to a string would help.
Either way, I'm running the search through the Examine Inspector to just filter the dates first to see if that brings anything back -but it doesnt...
Tim,
Open examine inspector do a search for any document that has the date field. Then click on the result it should open up a popup that will show you how all fields are indexed. Can you show how that date field is stored e.g I - Indexed; T - Tokenized; S - Stored, V - Term Vector also when you injected the field in did you do it using gatheringnode data event?
regards
Ismail
Thanks Ismail. This is what I have...
Don't mean to bug but any other ideas Ismail?
can u ping me on skype and screen share. also me and warren tried to contact you for uhangout we wnated to solve your issue with live coding session but he couldnt get hold of you.
Cheers.
I saw that email come through but figured it was a reminder of the uHangouts and didn't read.
Can you add me on Skype, I don't think I've got you setup -timgaunt
I've actually sorted this when we re-wrote the search logic last night but thanks for your help :)
what was the issue?
is working on a reply...