-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Describe the bug
Currently, range queries on date fields that use now bypass the ApproximatePointRangeQuery optimization path and instead wrap the underlying query in a DateRangeIncludingNowQuery. This results in full execution rather than benefiting from approximation.
Example the following query does not go through the approximation path
curl -X POST "http://localhost:9200/logs-*/_search" -H "Content-Type: application/json" -d '
{
"query": {
"range": {
"@timestamp": {
"gte": "1998-05-15T00:00:00Z",
"lt": "now"
}
}
}
}'
Related component
Search:Performance
To Reproduce
Once we have this #18318 implemented, using profile would be straight forward to see if the query is using the approximation path.
For now add a print statements in canApproximate and run a range query with now and see it does print the statements as it does not go through the ApproximateScoreQuery.
Expected behavior
Update handleNow or the surrounding logic (DateRangeIncludingNowQuery) to ensure that ApproximatePointRangeQuery is still used even when now is present.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status