-
Notifications
You must be signed in to change notification settings - Fork 25.6k
[Docs] Correct date rounding example for range query
#51524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
|
Pinging @elastic/es-search (:Search/Search) |
|
Pinging @elastic/es-docs (>docs) |
range queryrange query
cbuescher
left a comment
There was a problem hiding this 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));
}
|
@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? |
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 #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 #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 #50237 I realized that two of the examples given in the
documentation around date math rounding for range queries on date fields using
gtandltis slightly off by a nanosecond. This PR changes this to thebounds that are currently parsed using these parameters.