Skip to content
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
b7e8480
feature: keyword ignore_above
salvatore-campagna Sep 13, 2024
86d9320
feature: flattened ignore_above
salvatore-campagna Sep 13, 2024
b4d6ba5
feature: wildcard ignore_above
salvatore-campagna Sep 13, 2024
bfa4c78
fix: add missing ignore_above validator
salvatore-campagna Sep 13, 2024
8e081d4
feature: ignore_above_setting min value
salvatore-campagna Sep 13, 2024
d1362dc
fix: DynamicFieldsBuilder keyword ignore_above
salvatore-campagna Sep 13, 2024
db3e5a9
fix: percolator keyword
salvatore-campagna Sep 13, 2024
dfe87f3
fix: semantic text keyword
salvatore-campagna Sep 13, 2024
05166ba
fix: test using keyword, wildcard and flattened fields
salvatore-campagna Sep 13, 2024
4fcbb9f
fix: npe on preculdeParameters
salvatore-campagna Sep 13, 2024
adbd742
fix: incorrect method call
salvatore-campagna Sep 13, 2024
40629b8
fix: remove unused ignoreAbove() method
salvatore-campagna Sep 13, 2024
fdae006
test: yaml keyword, flattened and wildcard with stored and synthetic …
salvatore-campagna Sep 13, 2024
ac5cd94
Merge branch 'main' into feature/ignore-above-index-setting
salvatore-campagna Sep 18, 2024
97f0a13
fix: issues after merging and yaml required features
salvatore-campagna Sep 18, 2024
c2fbbc1
fix: require mapper validation feature
salvatore-campagna Sep 18, 2024
639e417
Merge branch 'main' into feature/ignore-above-index-setting
salvatore-campagna Sep 19, 2024
651dae7
test: date field type not filtered by ignore_above
salvatore-campagna Sep 19, 2024
44bd264
fix: use mapper.ignore_above_index_level_setting
salvatore-campagna Sep 19, 2024
63f6f44
skip runtime test on ignore_above setting
salvatore-campagna Sep 19, 2024
8205fc2
fix: some finals
salvatore-campagna Sep 19, 2024
7145301
comment: spik reason
salvatore-campagna Sep 19, 2024
e4beb91
fix: class cast exception
salvatore-campagna Sep 20, 2024
f88c36e
fix: play safe
salvatore-campagna Sep 20, 2024
a90ac4e
fix: bad merge
salvatore-campagna Sep 20, 2024
8f84e26
fix: make sure flattened is null
salvatore-campagna Sep 20, 2024
4e09c71
comment: remove flattened field issue link
salvatore-campagna Sep 20, 2024
95e1d3b
fix: extract static builder method
salvatore-campagna Sep 20, 2024
3d7c712
fix: more ignore_above index setting
salvatore-campagna Sep 20, 2024
3ea3b9b
nit: include a new KeywordFieldMapper constructor
salvatore-campagna Sep 20, 2024
e52e868
refactor: KeywordFieldMapper.Builder
salvatore-campagna Sep 20, 2024
f0a439d
fix: remove outdated comment
salvatore-campagna Sep 20, 2024
46609ea
nit: skip variable creation
salvatore-campagna Sep 20, 2024
736a05d
refactor: WildcardFieldMapper.Builder
salvatore-campagna Sep 20, 2024
1496798
refactor: FlattenedFieldMapper.Builder
salvatore-campagna Sep 20, 2024
0cf78c5
refactor: remove buildForTest
salvatore-campagna Sep 20, 2024
8d3ee09
revert: public to package protected
salvatore-campagna Sep 20, 2024
5e952a1
fix: missing constructor parameter
salvatore-campagna Sep 20, 2024
a886f2b
docs: index.mapping.ignore_above
salvatore-campagna Sep 20, 2024
38ac0f4
docs: improve documentation
salvatore-campagna Sep 20, 2024
127b519
Merge branch 'main' into feature/ignore-above-index-setting
salvatore-campagna Sep 20, 2024
f8b23e1
docs: improve javadoc and asciidoc for ignore_above
salvatore-campagna Sep 20, 2024
3cc33f3
Merge branch 'main' into feature/ignore-above-index-setting
salvatore-campagna Sep 20, 2024
b2b4015
fix: move IGNORE_ABOVE_INDEX_LEVEL_SETTING to IndexSettings
salvatore-campagna Sep 23, 2024
9603ddb
Merge branch 'main' into feature/ignore-above-index-setting
salvatore-campagna Sep 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import org.elasticsearch.compute.operator.topn.TopNOperator;
import org.elasticsearch.core.IOUtils;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.mapper.BlockLoader;
import org.elasticsearch.index.mapper.FieldNamesFieldMapper;
import org.elasticsearch.index.mapper.KeywordFieldMapper;
Expand Down Expand Up @@ -183,7 +182,7 @@ private static BlockLoader blockLoader(String name) {
Lucene.KEYWORD_ANALYZER,
Lucene.KEYWORD_ANALYZER,
Lucene.KEYWORD_ANALYZER,
new KeywordFieldMapper.Builder(name, IndexVersion.current()).docValues(ft.docValuesType() != DocValuesType.NONE),
KeywordFieldMapper.buildForTest(name, ft.docValuesType() != DocValuesType.NONE),
syntheticSource
).blockLoader(new MappedFieldType.BlockLoaderContext() {
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
---
ignore_above mapping level setting:
- requires:
cluster_features: [ "mapper.ignore_above_index_level_setting" ]
reason: introduce ignore_above index level setting
- do:
indices.create:
index: test
body:
settings:
index:
mapping:
ignore_above: 10
mappings:
properties:
keyword:
type: keyword
flattened:
type: flattened

- do:
index:
index: test
refresh: true
id: "1"
body: { "keyword": "foo bar", "flattened": { "value": "the quick brown fox" } }

- do:
search:
body:
fields:
- keyword
- flattened
query:
match_all: {}

- length: { hits.hits: 1 }
- match: { hits.hits.0._source.keyword: "foo bar" }
- match: { hits.hits.0._source.flattened.value: "the quick brown fox" }
- match: { hits.hits.0.fields.keyword.0: "foo bar" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we assert that flattened is null?

- match: { hits.hits.0.fields.flattened: null }

---
ignore_above mapping level setting on arrays:
- requires:
cluster_features: [ "mapper.ignore_above_index_level_setting" ]
reason: introduce ignore_above index level setting
- do:
indices.create:
index: test
body:
settings:
index:
mapping:
ignore_above: 10
mappings:
properties:
keyword:
type: keyword
flattened:
type: flattened

- do:
index:
index: test
refresh: true
id: "1"
body: { "keyword": ["foo bar", "the quick brown fox"], "flattened": { "value": ["the quick brown fox", "jumps over"] } }

- do:
search:
body:
fields:
- keyword
- flattened
query:
match_all: {}

- length: { hits.hits: 1 }
- match: { hits.hits.0._source.keyword: ["foo bar", "the quick brown fox"] }
- match: { hits.hits.0._source.flattened.value: ["the quick brown fox", "jumps over"] }
- match: { hits.hits.0.fields.keyword.0: "foo bar" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assert that length is 1?

Copy link
Contributor Author

@salvatore-campagna salvatore-campagna Sep 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If length is not 1 this match would fail, right? And the failure would be something like

expected "foo bar" but was "[foo bar", "baz bax"]

or

expected "foo bar" but was null

Copy link
Contributor Author

@salvatore-campagna salvatore-campagna Sep 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moreover if I assert the length before asserting the match a test would fail with something like

expected length 1 but was 2 m(or whatever)

while I think is a bit better to actually see the field values in the error message. We would need to re-run the test removing the length assertion to see which value is returned.

- match: { hits.hits.0.fields.flattened.0.value: "jumps over" }

---
ignore_above mapping overrides setting:
- requires:
cluster_features: [ "mapper.ignore_above_index_level_setting" ]
reason: introduce ignore_above index level setting
- do:
indices.create:
index: test
body:
settings:
index:
mapping:
ignore_above: 10
mappings:
properties:
keyword:
type: keyword
ignore_above: 100
flattened:
type: flattened
ignore_above: 100

- do:
index:
index: test
refresh: true
id: "1"
body: { "keyword": "foo bar baz foo bar baz", "flattened": { "value": "the quick brown fox" } }

- do:
search:
body:
fields:
- keyword
- flattened
query:
match_all: { }

- length: { hits.hits: 1 }
- match: { hits.hits.0._source.keyword: "foo bar baz foo bar baz" }
- match: { hits.hits.0._source.flattened.value: "the quick brown fox" }
- match: { hits.hits.0.fields.keyword.0: "foo bar baz foo bar baz" }
- match: { hits.hits.0.fields.flattened.0.value: "the quick brown fox" }

---
ignore_above mapping overrides setting on arrays:
- requires:
cluster_features: [ "mapper.ignore_above_index_level_setting" ]
reason: introduce ignore_above index level setting
- do:
indices.create:
index: test
body:
settings:
index:
mapping:
ignore_above: 10
mappings:
properties:
keyword:
type: keyword
ignore_above: 100
flattened:
type: flattened
ignore_above: 100

- do:
index:
index: test
refresh: true
id: "1"
body: { "keyword": ["foo bar baz foo bar baz", "the quick brown fox jumps over"], "flattened": { "value": ["the quick brown fox", "jumps over the lazy dog"] } }

- do:
search:
body:
fields:
- keyword
- flattened
query:
match_all: { }

- length: { hits.hits: 1 }
- match: { hits.hits.0._source.keyword: ["foo bar baz foo bar baz", "the quick brown fox jumps over"] }
- match: { hits.hits.0._source.flattened.value: ["the quick brown fox", "jumps over the lazy dog"] }
- match: { hits.hits.0.fields.keyword: ["foo bar baz foo bar baz", "the quick brown fox jumps over"] }
- match: { hits.hits.0.fields.flattened.0.value: ["the quick brown fox", "jumps over the lazy dog"] }

---
date ignore_above index level setting:
- requires:
cluster_features: [ "mapper.ignore_above_index_level_setting" ]
reason: introduce ignore_above index level setting
- do:
indices.create:
index: test
body:
settings:
index:
mapping:
ignore_above: 10
mappings:
properties:
keyword:
type: keyword
date:
type: date
format: "yyyy-MM-dd'T'HH:mm:ss"

- do:
index:
index: test
refresh: true
id: "1"
body: { "keyword": ["2023-09-17T15:30:00", "2023-09-17T15:31:00"], "date": ["2023-09-17T15:30:00", "2023-09-17T15:31:00"] }

- do:
search:
body:
fields:
- keyword
- date
query:
match_all: {}

- length: { hits.hits: 1 }
- match: { hits.hits.0._source.keyword: ["2023-09-17T15:30:00", "2023-09-17T15:31:00"] }
- match: { hits.hits.0._source.date: ["2023-09-17T15:30:00", "2023-09-17T15:31:00"] }
- match: { hits.hits.0.fields.keyword: null }
- match: { hits.hits.0.fields.date: ["2023-09-17T15:30:00","2023-09-17T15:31:00"] }
Loading