From 1580fc70bded10798b171d0e43ed3949f85e746f Mon Sep 17 00:00:00 2001 From: Luca Cavanna Date: Sat, 19 Sep 2020 00:24:44 +0200 Subject: [PATCH] Minor FlatObjectFieldMapper fix (#62633) The splitQueriesOnWhitespace instance field can be made final, and setter and getter are not always needed. --- .../mapper/FlatObjectFieldMapper.java | 24 +++---------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/mapper/FlatObjectFieldMapper.java b/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/mapper/FlatObjectFieldMapper.java index 50873db8638..169a59c089b 100644 --- a/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/mapper/FlatObjectFieldMapper.java +++ b/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/mapper/FlatObjectFieldMapper.java @@ -227,7 +227,6 @@ public final class FlatObjectFieldMapper extends DynamicKeyFieldMapper { */ public static final class KeyedFlatObjectFieldType extends StringFieldType { private final String key; - private boolean splitQueriesOnWhitespace; public KeyedFlatObjectFieldType(String name, boolean indexed, boolean hasDocValues, String key, boolean splitQueriesOnWhitespace, Map meta) { @@ -236,7 +235,6 @@ public final class FlatObjectFieldMapper extends DynamicKeyFieldMapper { meta); setIndexAnalyzer(Lucene.KEYWORD_ANALYZER); this.key = key; - this.splitQueriesOnWhitespace = splitQueriesOnWhitespace; } private KeyedFlatObjectFieldType(String name, String key, RootFlatObjectFieldType ref) { @@ -252,14 +250,6 @@ public final class FlatObjectFieldMapper extends DynamicKeyFieldMapper { return key; } - public boolean splitQueriesOnWhitespace() { - return splitQueriesOnWhitespace; - } - - public void setSplitQueriesOnWhitespace(boolean splitQueriesOnWhitespace) { - this.splitQueriesOnWhitespace = splitQueriesOnWhitespace; - } - @Override public Query existsQuery(QueryShardContext context) { Term term = new Term(name(), FlatObjectFieldParser.createKeyedValue(key, "")); @@ -438,7 +428,7 @@ public final class FlatObjectFieldMapper extends DynamicKeyFieldMapper { * searches on the flat object field itself, e.g. 'my_flat_object: some_value'. */ public static final class RootFlatObjectFieldType extends StringFieldType { - private boolean splitQueriesOnWhitespace; + private final boolean splitQueriesOnWhitespace; public RootFlatObjectFieldType(String name, boolean indexed, boolean hasDocValues, Map meta, boolean splitQueriesOnWhitespace) { @@ -453,14 +443,6 @@ public final class FlatObjectFieldMapper extends DynamicKeyFieldMapper { return CONTENT_TYPE; } - public boolean splitQueriesOnWhitespace() { - return splitQueriesOnWhitespace; - } - - public void setSplitQueriesOnWhitespace(boolean splitQueriesOnWhitespace) { - this.splitQueriesOnWhitespace = splitQueriesOnWhitespace; - } - @Override public Object valueForDisplay(Object value) { if (value == null) { @@ -596,8 +578,8 @@ public final class FlatObjectFieldMapper extends DynamicKeyFieldMapper { builder.field("null_value", nullValue); } - if (includeDefaults || fieldType().splitQueriesOnWhitespace()) { - builder.field("split_queries_on_whitespace", fieldType().splitQueriesOnWhitespace()); + if (includeDefaults || fieldType().splitQueriesOnWhitespace) { + builder.field("split_queries_on_whitespace", fieldType().splitQueriesOnWhitespace); } } }