-
Notifications
You must be signed in to change notification settings - Fork 26
Description
Summary
AND criteria having one of the criteria with the date type field doesn't return any result.
Same date criteria returns a result if used alone(not as part of AND criteria).
dt = datetime.strptime("2019-11-10T00:00:00Z", "%Y-%m-%dT%H:%M:%SZ")
Criteria.with_field("some_date", Matcher.less_than(dt))
returns a result.
But won't return anything with True criteria within AND or any other possibly matching criteria. e.g.
Criteria.and_(Criteria.true(),
Criteria.with_field("some_date", Matcher.less_than(dt)))
Criteria.and_(Criteria.with_field("some_field", Matcher.regex("regex")),
Criteria.with_field("some_date", Matcher.less_than(dt)))
Criteria.and_(Criteria.with_field("some_other_field", Matcher.equals("value")),
Criteria.with_field("some_date", Matcher.less_than(dt)))
won't return anything (though there are possible matches).
AND criteria works for any other criteria with non-date fields. .e.g.
Criteria.and_(Criteria.with_field("some_field", Matcher.regex("regex")),
Criteria.true())
Criteria.and_(Criteria.with_field("some_field", Matcher.regex("regex")),
Criteria.with_field("some_other_field", Matcher.equals("value")))
returns the result.
Issue Type
- Bug Report
Steps to reproduce
Create a search request with AND criteria as mentioned in the description involving a date type field and verify with the expected result.
Actual results
search request with AND criteria doesn't return result when one of the conditions includes a date type field.
Expected results
search request with AND criteria should return the expected result even when one of the conditions involve a date type field
OS / Environment
Additional Information
- Similar request with OR criteria works fine i.e. returns expected result when one of the conditions involves a date type field.
- Currently, the json query generated for an AND criteria looks something like
{"$and":[{"some_date":{"$lt":{"$date":"2019-11-10T07:24:31Z"}}},{"regex_field":{"$regex": "regex"}}]}
which doesn't return any result. However, if this is modified to
{"some_date":{"$lt":{"$date":"2019-11-10T07:24:31Z"}}, "regex_field":{"$regex": "regex"}}
works fine as an AND criteria and returns the expected result.