Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tim 164 posts 325 karma points
    Oct 23, 2013 @ 12:11
    Tim
    0

    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

  • Ismail Mayat 4271 posts 9210 karma points MVP 2x admin c-trib
    Oct 23, 2013 @ 12:35
    Ismail Mayat
    1

    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

  • Tim 164 posts 325 karma points
    Oct 23, 2013 @ 13:02
    Tim
    0

    >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 });

  • Ismail Mayat 4271 posts 9210 karma points MVP 2x admin c-trib
    Oct 23, 2013 @ 13:30
    Ismail Mayat
    0

    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

  • Tim 164 posts 325 karma points
    Oct 23, 2013 @ 14:03
    Tim
    0

    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...

  • Ismail Mayat 4271 posts 9210 karma points MVP 2x admin c-trib
    Oct 23, 2013 @ 15:54
    Ismail Mayat
    0

    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

  • Tim 164 posts 325 karma points
    Oct 23, 2013 @ 16:33
    Tim
    0

     Thanks Ismail. This is what I have...

     

    FieldITSVboost
    <__luceneFriendlyStartDate> + + +   1
  • Tim 164 posts 325 karma points
    Oct 29, 2013 @ 16:59
    Tim
    0

    Don't mean to bug but any other ideas Ismail?

  • Ismail Mayat 4271 posts 9210 karma points MVP 2x admin c-trib
    Oct 29, 2013 @ 17:03
    Ismail Mayat
    0

    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.

  • Tim 164 posts 325 karma points
    Oct 29, 2013 @ 17:34
    Tim
    0

    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

  • Tim 164 posts 325 karma points
    Oct 30, 2013 @ 11:59
    Tim
    0

    I've actually sorted this when we re-wrote the search logic last night but thanks for your help :)

  • Ismail Mayat 4271 posts 9210 karma points MVP 2x admin c-trib
    Oct 30, 2013 @ 12:13
    Ismail Mayat
    0

    what was the issue?

Please Sign in or register to post replies

Write your reply to:

Draft