forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use SearchStats instead of field.isAggregatable in data node planning (…
…elastic#115744) Since ES|QL makes use of field-caps and only considers `isAggregatable` during Lucene pushdown, turning off doc-values disables Lucene pushdown. This is incorrect. The physical planning decision for Lucene pushdown is made during local planning on the data node, at which point `SearchStats` are known, and both `isIndexed` and `hasDocValues` are separately knowable. The Lucene pushdown should happen for `isIndexed` and not consider `hasDocValues` at all. This PR adds hasDocValues to SearchStats and the uses isIndexed and hasDocValue separately during local physical planning on the data nodes. This immediately cleared up one issue for spatial data, which could not push down a lucene query when doc-values was disabled. Summary of what `isAggregatable` means for different implementations of `MappedFieldType`: * Default implementation of `isAggregatable` in `MappedFieldType` is `hasDocValues`, and does not consider `isIndexed` * All classes that extend `AbstractScriptFieldType` (eg. `LongScriptFieldType`) hard coded `isAggregatable` to `true`. This presumably means Lucene is happy to mimic having doc-values * `TestFieldType`, and classes that extend it, return the value of `fielddata`, so consider the field aggregatable if there is field-data. * `AggregateDoubleMetricFieldType` and `ConstantFieldType` hard coded to `true` * `DenseVectorFieldType` hard coded to `false` * `IdFieldType` return the value of `fieldDataEnabled.getAsBoolean()` In no case is `isIndexed` used for `isAggregatable`. However, for our Lucene pushdown of filters, `isIndexed` would make a lot more sense. But for pushdown of TopN, `hasDocValues` makes more sense. Summarising the results of the various options for the various field types, where `?` means configrable: | Class | isAggregatable | isIndexed | isStored | hasDocValues | | --- | --- | --- | --- | --- | | AbstractScriptFieldType | true | false | false | false | | AggregateDoubleMetricFieldType | true | true | false | false | | DenseVectorFieldType | false | ? | false | !indexed | | IdFieldType | fieldData | true | true | false | | TsidExtractingIdField | false | true | true | false | | TextFieldType | fieldData | ? | ? | false | | ? (the rest) | hasDocValues | ? | ? | ? | It has also been observed that we cannot push filters to source without checking `hasDocValues` when we use the `SingleValueQuery`. So this leads to three groups of conditions: | Category | require `indexed` | require `docValues` | | --- | --- | --- | | Filters(single-value) | true | true | | Filters(multi-value) | true | false | | TopN | true | true | And for all cases we will also consider `isAggregatable` as a disjunction to cover the script field types, leading to two possible combinations: * `fa.isAggregatable() || searchStats.isIndexed(fa.name()) && searchStats.hasDocValues(fa.name())` * `fa.isAggregatable() || searchStats.isIndexed(fa.name())`
- Loading branch information
1 parent
8b8cf5f
commit 1164de1
Showing
26 changed files
with
1,049 additions
and
565 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pr: 115744 | ||
summary: Use `SearchStats` instead of field.isAggregatable in data node planning | ||
area: ES|QL | ||
type: bug | ||
issues: | ||
- 115737 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
x-pack/plugin/esql/qa/testFixtures/src/main/resources/mapping-airports_no_doc_values.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"properties": { | ||
"abbrev": { | ||
"type": "keyword" | ||
}, | ||
"name": { | ||
"type": "text" | ||
}, | ||
"scalerank": { | ||
"type": "integer" | ||
}, | ||
"type": { | ||
"type": "keyword" | ||
}, | ||
"location": { | ||
"type": "geo_point", | ||
"index": true, | ||
"doc_values": false | ||
}, | ||
"country": { | ||
"type": "keyword" | ||
}, | ||
"city": { | ||
"type": "keyword" | ||
}, | ||
"city_location": { | ||
"type": "geo_point" | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
x-pack/plugin/esql/qa/testFixtures/src/main/resources/mapping-airports_not_indexed.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"properties": { | ||
"abbrev": { | ||
"type": "keyword" | ||
}, | ||
"name": { | ||
"type": "text" | ||
}, | ||
"scalerank": { | ||
"type": "integer" | ||
}, | ||
"type": { | ||
"type": "keyword" | ||
}, | ||
"location": { | ||
"type": "geo_point", | ||
"index": false, | ||
"doc_values": true | ||
}, | ||
"country": { | ||
"type": "keyword" | ||
}, | ||
"city": { | ||
"type": "keyword" | ||
}, | ||
"city_location": { | ||
"type": "geo_point" | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.