Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add index mapping parameter for counted_keyword (#103646)
With this commit we add a new mapping parameter `index` to the `counted_keyword` mapping type. This allows to reduce disk usage for use cases where indexed fields are not required. Relates #101826
- Loading branch information
1 parent
de502db
commit 53296e2
Showing
5 changed files
with
109 additions
and
12 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,5 @@ | ||
pr: 103646 | ||
summary: Add index mapping parameter for `counted_keyword` | ||
area: Aggregations | ||
type: enhancement | ||
issues: [] |
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
54 changes: 54 additions & 0 deletions
54
x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/counted_keyword/20_no_index.yml
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,54 @@ | ||
setup: | ||
|
||
- skip: | ||
version: " - 8.12.99" | ||
reason: "index option on counted_keyword was added in 8.13" | ||
|
||
- do: | ||
indices.create: | ||
index: test-events-no-index | ||
body: | ||
mappings: | ||
properties: | ||
events: | ||
type: counted_keyword | ||
index: false | ||
|
||
- do: | ||
index: | ||
index: test-events-no-index | ||
id: "1" | ||
body: { "events": [ "a", "a", "b" ] } | ||
|
||
|
||
- do: | ||
indices.refresh: { } | ||
|
||
--- | ||
"Counted keyword with index false is not searchable": | ||
- do: | ||
field_caps: | ||
index: test-events-no-index | ||
fields: [ events ] | ||
|
||
- match: { fields.events.counted_keyword.searchable: false } | ||
- match: { fields.events.counted_keyword.aggregatable: true } | ||
|
||
--- | ||
"Counted Terms agg only relies on doc values": | ||
# although the field is not indexed, the counted_terms agg should still work | ||
- do: | ||
search: | ||
index: test-events-no-index | ||
body: | ||
size: 0 | ||
aggs: | ||
event_terms: | ||
counted_terms: | ||
field: events | ||
|
||
- match: { aggregations.event_terms.buckets.0.key: "a" } | ||
- match: { aggregations.event_terms.buckets.0.doc_count: 2 } | ||
- match: { aggregations.event_terms.buckets.1.key: "b" } | ||
- match: { aggregations.event_terms.buckets.1.doc_count: 1 } | ||
- length: { aggregations.event_terms.buckets: 2 } |