Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.4
    • Component/s: None
    • Labels:
      None

      Description

      ms (milliseconds) function to use dates in function queries

      1. SOLR-1368.patch
        18 kB
        Yonik Seeley
      2. SOLR-1368.patch
        13 kB
        Yonik Seeley

        Activity

        Hide
        Yonik Seeley added a comment -

        Floats sometimes don't have sufficient precision for subtracting dates:
        http://search.lucidimagination.com/search/document/be9fcf5bbc8fd574/date_functions_and_floats

        An ms() function both provides a way to introduce date constants, as well as subtract them.

        examples:
        ms(NOW) a constant
        ms(2009-12-14T01:01:01Z) a constant
        ms(field) a date field (needs to be a trie-date variant that has milliseconds available)
        ms(field1,field2) difference in milliseconds
        ms(NOW/SECOND,field1) difference in milliseconds

        Show
        Yonik Seeley added a comment - Floats sometimes don't have sufficient precision for subtracting dates: http://search.lucidimagination.com/search/document/be9fcf5bbc8fd574/date_functions_and_floats An ms() function both provides a way to introduce date constants, as well as subtract them. examples: ms(NOW) a constant ms(2009-12-14T01:01:01Z) a constant ms(field) a date field (needs to be a trie-date variant that has milliseconds available) ms(field1,field2) difference in milliseconds ms(NOW/SECOND,field1) difference in milliseconds
        Hide
        Yonik Seeley added a comment -

        Attaching a draft of a patch that seems to work - still needs tests.

        Show
        Yonik Seeley added a comment - Attaching a draft of a patch that seems to work - still needs tests.
        Hide
        Hoss Man added a comment -

        ms(field) a date field (needs to be a trie-date variant that has milliseconds available)

        why?

        if it's legal to call ms on a rounded date (ie: NOW/SECOND) then why shouldn't it be legal to use a trie field with coarse precision?

        Show
        Hoss Man added a comment - ms(field) a date field (needs to be a trie-date variant that has milliseconds available) why? if it's legal to call ms on a rounded date (ie: NOW/SECOND) then why shouldn't it be legal to use a trie field with coarse precision?
        Hide
        Yonik Seeley added a comment -

        if it's legal to call ms on a rounded date (ie: NOW/SECOND) then why shouldn't it be legal to use a trie field with coarse precision?

        It should (and I do have plans for that in the future). What I meant by that is the newer trie based fields are the only ones you can get milliseconds from (regardless of precision) as opposed to a date string. It's not practical to convert date strings to milliseconds/seconds on the fly from the fieldcache. Perhaps we should throw an exception rather than silently using ord for those string-date fields though?

        Show
        Yonik Seeley added a comment - if it's legal to call ms on a rounded date (ie: NOW/SECOND) then why shouldn't it be legal to use a trie field with coarse precision? It should (and I do have plans for that in the future). What I meant by that is the newer trie based fields are the only ones you can get milliseconds from (regardless of precision) as opposed to a date string. It's not practical to convert date strings to milliseconds/seconds on the fly from the fieldcache. Perhaps we should throw an exception rather than silently using ord for those string-date fields though?
        Hide
        Yonik Seeley added a comment -

        Attaching new patch with tests.
        This now throws an exception if ms() is used on string-based date fields (as opposed to numeric/trie).

        Show
        Yonik Seeley added a comment - Attaching new patch with tests. This now throws an exception if ms() is used on string-based date fields (as opposed to numeric/trie).
        Hide
        Grant Ingersoll added a comment -

        Bulk close for Solr 1.4

        Show
        Grant Ingersoll added a comment - Bulk close for Solr 1.4

          People

          • Assignee:
            Yonik Seeley
            Reporter:
            Yonik Seeley
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development