Skip to content

Conversation

@cbuescher
Copy link
Member

Looking into #50237 I realized that two of the examples given in the
documentation around date math rounding for range queries on date fields using
gt and lt is slightly off by a nanosecond. This PR changes this to the
bounds that are currently parsed using these parameters.

Looking into elastic#50237 I realized that two of the examples given in the
documentation around date math rounding for range queries on date fields using
`gt` and `lt` is slightly off by a nanosecond. This PR changes this to the
bounds that are currently parsed using these parameters.
@cbuescher cbuescher added >docs General docs changes :Search/Search Search-related issues that do not fall into other categories v8.0.0 v7.6.1 v7.5.3 labels Jan 28, 2020
@cbuescher cbuescher requested a review from jpountz January 28, 2020 10:45
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/Search)

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-docs (>docs)

@cbuescher cbuescher changed the title [Docs] Correct date rounding for range query [Docs] Correct date rounding example for range query Jan 28, 2020
Copy link
Member Author

@cbuescher cbuescher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code used to check the differing gt and lt bounds, e.g. run this in RangeFieldTypeTests:

public void testCheckBoundsOnDateFieldType() {
        String dateString = "2014-11-18||/M";
        boolean includeLower = false;
        boolean includeUpper = false;
        DateFieldType dateFieldType = new DateFieldType();

        final DateFormatter formatter = DateFormatter.forPattern("yyyy-MM-dd");
        dateFieldType.setName("field");
        dateFieldType.setDateTimeFormatter(formatter);

        QueryShardContext context = createContext();
        Query query = dateFieldType.rangeQuery(dateString, null, includeLower, includeUpper, ShapeRelation.INTERSECTS, null, null, context);
        assertEquals("field:[1417392000000 TO 9223372036854775807]", query.toString());
        final DateFormatter fullFormatter = DateFormatter.forPattern("strictDateTime");
        assertEquals("2014-12-01T00:00:00.000Z", fullFormatter.formatMillis(1417392000000l));

        query = dateFieldType.rangeQuery(null, dateString, includeLower, includeUpper, ShapeRelation.INTERSECTS, null, null, context);
        assertEquals("field:[-9223372036854775808 TO 1414799999999]", query.toString());
        assertEquals("2014-10-31T23:59:59.999Z", fullFormatter.formatMillis(1414799999999l));
    }

@ywelsch ywelsch added v7.6.2 and removed v7.6.1 labels Feb 27, 2020
@jimczi jimczi added v7.7.0 and removed v7.6.2 labels Mar 18, 2020
@bpintea bpintea added v7.8.0 and removed v7.7.0 labels Mar 25, 2020
@cbuescher cbuescher removed the v7.5.3 label Mar 30, 2020
@cbuescher
Copy link
Member Author

@jpountz I just found this looking through my open PRs and updated it with a small correction regarding the rounding resolution, I think the change still applies and I'd like to get it into the current docs. Would you mind taking a look or let me know if I should ask for another review if you don't find the time?

@cbuescher cbuescher merged commit 440fb48 into elastic:master Apr 6, 2020
cbuescher pushed a commit that referenced this pull request Apr 6, 2020
Looking into #50237 I realized that two of the examples given in the
documentation around date math rounding for range queries on date fields using
`gt` and `lt` is slightly off by a nanosecond. This PR changes this to the
bounds that are currently parsed using these parameters.
cbuescher pushed a commit that referenced this pull request Apr 6, 2020
Looking into #50237 I realized that two of the examples given in the
documentation around date math rounding for range queries on date fields using
`gt` and `lt` is slightly off by a nanosecond. This PR changes this to the
bounds that are currently parsed using these parameters.
cbuescher pushed a commit that referenced this pull request Apr 6, 2020
Looking into #50237 I realized that two of the examples given in the
documentation around date math rounding for range queries on date fields using
`gt` and `lt` is slightly off by a nanosecond. This PR changes this to the
bounds that are currently parsed using these parameters.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>docs General docs changes :Search/Search Search-related issues that do not fall into other categories v7.8.0 v8.0.0-alpha1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants