30
30
import org .elasticsearch .index .fielddata .plain .BytesBinaryDVIndexFieldData ;
31
31
import org .elasticsearch .index .fielddata .plain .DisabledIndexFieldData ;
32
32
import org .elasticsearch .index .fielddata .plain .DocValuesIndexFieldData ;
33
- import org .elasticsearch .index .fielddata .plain .DoubleArrayIndexFieldData ;
34
- import org .elasticsearch .index .fielddata .plain .FloatArrayIndexFieldData ;
35
33
import org .elasticsearch .index .fielddata .plain .GeoPointBinaryDVIndexFieldData ;
36
34
import org .elasticsearch .index .fielddata .plain .GeoPointDoubleArrayIndexFieldData ;
37
35
import org .elasticsearch .index .fielddata .plain .IndexIndexFieldData ;
38
- import org .elasticsearch .index .fielddata .plain .PackedArrayIndexFieldData ;
39
36
import org .elasticsearch .index .fielddata .plain .PagedBytesIndexFieldData ;
40
37
import org .elasticsearch .index .fielddata .plain .ParentChildIndexFieldData ;
41
38
import org .elasticsearch .index .mapper .MappedFieldType ;
@@ -64,9 +61,18 @@ public class IndexFieldDataService extends AbstractIndexComponent {
64
61
public static final String FIELDDATA_CACHE_KEY = "index.fielddata.cache" ;
65
62
public static final String FIELDDATA_CACHE_VALUE_NODE = "node" ;
66
63
64
+ private static final IndexFieldData .Builder MISSING_DOC_VALUES_BUILDER = new IndexFieldData .Builder () {
65
+ @ Override
66
+ public IndexFieldData <?> build (Index index , Settings indexSettings , MappedFieldType fieldType , IndexFieldDataCache cache , CircuitBreakerService breakerService , MapperService mapperService ) {
67
+ throw new IllegalStateException ("Can't load fielddata on [" + fieldType .names ().fullName ()
68
+ + "] of index [" + index .getName () + "] because fielddata is unsupported on fields of type ["
69
+ + fieldType .fieldDataType ().getType () + "]. Use doc values instead." );
70
+ }
71
+ };
72
+
73
+ private static final String ARRAY_FORMAT = "array" ;
67
74
private static final String DISABLED_FORMAT = "disabled" ;
68
75
private static final String DOC_VALUES_FORMAT = "doc_values" ;
69
- private static final String ARRAY_FORMAT = "array" ;
70
76
private static final String PAGED_BYTES_FORMAT = "paged_bytes" ;
71
77
72
78
private final static Map <String , IndexFieldData .Builder > buildersByType ;
@@ -77,19 +83,18 @@ public class IndexFieldDataService extends AbstractIndexComponent {
77
83
static {
78
84
Map <String , IndexFieldData .Builder > buildersByTypeBuilder = new HashMap <>();
79
85
buildersByTypeBuilder .put ("string" , new PagedBytesIndexFieldData .Builder ());
80
- buildersByTypeBuilder .put ("float" , new FloatArrayIndexFieldData . Builder () );
81
- buildersByTypeBuilder .put ("double" , new DoubleArrayIndexFieldData . Builder () );
82
- buildersByTypeBuilder .put ("byte" , new PackedArrayIndexFieldData . Builder (). setNumericType ( IndexNumericFieldData . NumericType . BYTE ) );
83
- buildersByTypeBuilder .put ("short" , new PackedArrayIndexFieldData . Builder (). setNumericType ( IndexNumericFieldData . NumericType . SHORT ) );
84
- buildersByTypeBuilder .put ("int" , new PackedArrayIndexFieldData . Builder (). setNumericType ( IndexNumericFieldData . NumericType . INT ) );
85
- buildersByTypeBuilder .put ("long" , new PackedArrayIndexFieldData . Builder (). setNumericType ( IndexNumericFieldData . NumericType . LONG ) );
86
+ buildersByTypeBuilder .put ("float" , MISSING_DOC_VALUES_BUILDER );
87
+ buildersByTypeBuilder .put ("double" , MISSING_DOC_VALUES_BUILDER );
88
+ buildersByTypeBuilder .put ("byte" , MISSING_DOC_VALUES_BUILDER );
89
+ buildersByTypeBuilder .put ("short" , MISSING_DOC_VALUES_BUILDER );
90
+ buildersByTypeBuilder .put ("int" , MISSING_DOC_VALUES_BUILDER );
91
+ buildersByTypeBuilder .put ("long" , MISSING_DOC_VALUES_BUILDER );
86
92
buildersByTypeBuilder .put ("geo_point" , new GeoPointDoubleArrayIndexFieldData .Builder ());
87
93
buildersByTypeBuilder .put (ParentFieldMapper .NAME , new ParentChildIndexFieldData .Builder ());
88
94
buildersByTypeBuilder .put (IndexFieldMapper .NAME , new IndexIndexFieldData .Builder ());
89
95
buildersByTypeBuilder .put ("binary" , new DisabledIndexFieldData .Builder ());
90
- buildersByTypeBuilder .put (BooleanFieldMapper .CONTENT_TYPE ,
91
- new PackedArrayIndexFieldData .Builder ().setNumericType (IndexNumericFieldData .NumericType .BOOLEAN ));
92
- buildersByType = unmodifiableMap (buildersByTypeBuilder );
96
+ buildersByTypeBuilder .put (BooleanFieldMapper .CONTENT_TYPE , MISSING_DOC_VALUES_BUILDER );
97
+ buildersByType = unmodifiableMap (buildersByTypeBuilder );
93
98
94
99
95
100
docValuesBuildersByType = MapBuilder .<String , IndexFieldData .Builder >newMapBuilder ()
@@ -110,27 +115,21 @@ public class IndexFieldDataService extends AbstractIndexComponent {
110
115
.put (Tuple .tuple ("string" , DOC_VALUES_FORMAT ), new DocValuesIndexFieldData .Builder ())
111
116
.put (Tuple .tuple ("string" , DISABLED_FORMAT ), new DisabledIndexFieldData .Builder ())
112
117
113
- .put (Tuple .tuple ("float" , ARRAY_FORMAT ), new FloatArrayIndexFieldData .Builder ())
114
118
.put (Tuple .tuple ("float" , DOC_VALUES_FORMAT ), new DocValuesIndexFieldData .Builder ().numericType (IndexNumericFieldData .NumericType .FLOAT ))
115
119
.put (Tuple .tuple ("float" , DISABLED_FORMAT ), new DisabledIndexFieldData .Builder ())
116
120
117
- .put (Tuple .tuple ("double" , ARRAY_FORMAT ), new DoubleArrayIndexFieldData .Builder ())
118
121
.put (Tuple .tuple ("double" , DOC_VALUES_FORMAT ), new DocValuesIndexFieldData .Builder ().numericType (IndexNumericFieldData .NumericType .DOUBLE ))
119
122
.put (Tuple .tuple ("double" , DISABLED_FORMAT ), new DisabledIndexFieldData .Builder ())
120
123
121
- .put (Tuple .tuple ("byte" , ARRAY_FORMAT ), new PackedArrayIndexFieldData .Builder ().setNumericType (IndexNumericFieldData .NumericType .BYTE ))
122
124
.put (Tuple .tuple ("byte" , DOC_VALUES_FORMAT ), new DocValuesIndexFieldData .Builder ().numericType (IndexNumericFieldData .NumericType .BYTE ))
123
125
.put (Tuple .tuple ("byte" , DISABLED_FORMAT ), new DisabledIndexFieldData .Builder ())
124
126
125
- .put (Tuple .tuple ("short" , ARRAY_FORMAT ), new PackedArrayIndexFieldData .Builder ().setNumericType (IndexNumericFieldData .NumericType .SHORT ))
126
127
.put (Tuple .tuple ("short" , DOC_VALUES_FORMAT ), new DocValuesIndexFieldData .Builder ().numericType (IndexNumericFieldData .NumericType .SHORT ))
127
128
.put (Tuple .tuple ("short" , DISABLED_FORMAT ), new DisabledIndexFieldData .Builder ())
128
129
129
- .put (Tuple .tuple ("int" , ARRAY_FORMAT ), new PackedArrayIndexFieldData .Builder ().setNumericType (IndexNumericFieldData .NumericType .INT ))
130
130
.put (Tuple .tuple ("int" , DOC_VALUES_FORMAT ), new DocValuesIndexFieldData .Builder ().numericType (IndexNumericFieldData .NumericType .INT ))
131
131
.put (Tuple .tuple ("int" , DISABLED_FORMAT ), new DisabledIndexFieldData .Builder ())
132
132
133
- .put (Tuple .tuple ("long" , ARRAY_FORMAT ), new PackedArrayIndexFieldData .Builder ().setNumericType (IndexNumericFieldData .NumericType .LONG ))
134
133
.put (Tuple .tuple ("long" , DOC_VALUES_FORMAT ), new DocValuesIndexFieldData .Builder ().numericType (IndexNumericFieldData .NumericType .LONG ))
135
134
.put (Tuple .tuple ("long" , DISABLED_FORMAT ), new DisabledIndexFieldData .Builder ())
136
135
@@ -141,7 +140,6 @@ public class IndexFieldDataService extends AbstractIndexComponent {
141
140
.put (Tuple .tuple ("binary" , DOC_VALUES_FORMAT ), new BytesBinaryDVIndexFieldData .Builder ())
142
141
.put (Tuple .tuple ("binary" , DISABLED_FORMAT ), new DisabledIndexFieldData .Builder ())
143
142
144
- .put (Tuple .tuple (BooleanFieldMapper .CONTENT_TYPE , ARRAY_FORMAT ), new PackedArrayIndexFieldData .Builder ().setNumericType (IndexNumericFieldData .NumericType .BOOLEAN ))
145
143
.put (Tuple .tuple (BooleanFieldMapper .CONTENT_TYPE , DOC_VALUES_FORMAT ), new DocValuesIndexFieldData .Builder ().numericType (IndexNumericFieldData .NumericType .BOOLEAN ))
146
144
.put (Tuple .tuple (BooleanFieldMapper .CONTENT_TYPE , DISABLED_FORMAT ), new DisabledIndexFieldData .Builder ())
147
145
@@ -163,12 +161,6 @@ public void onRemoval(ShardId shardId, Names fieldNames, FieldDataType fieldData
163
161
};
164
162
private volatile IndexFieldDataCache .Listener listener = DEFAULT_NOOP_LISTENER ;
165
163
166
-
167
- // We need to cache fielddata on the _parent field because of 1.x indices.
168
- // When we don't support 1.x anymore (3.0) then remove this caching
169
- // This variable needs to be read/written under lock
170
- private IndexFieldData <?> parentIndexFieldData ;
171
-
172
164
@ Inject
173
165
public IndexFieldDataService (Index index , @ IndexSettings Settings indexSettings , IndicesFieldDataCache indicesFieldDataCache ,
174
166
CircuitBreakerService circuitBreakerService , MapperService mapperService ) {
@@ -179,7 +171,6 @@ public IndexFieldDataService(Index index, @IndexSettings Settings indexSettings,
179
171
}
180
172
181
173
public synchronized void clear () {
182
- parentIndexFieldData = null ;
183
174
List <Throwable > exceptions = new ArrayList <>(0 );
184
175
final Collection <IndexFieldDataCache > fieldDataCacheValues = fieldDataCaches .values ();
185
176
for (IndexFieldDataCache cache : fieldDataCacheValues ) {
@@ -194,9 +185,6 @@ public synchronized void clear() {
194
185
}
195
186
196
187
public synchronized void clearField (final String fieldName ) {
197
- if (ParentFieldMapper .NAME .equals (fieldName )) {
198
- parentIndexFieldData = null ;
199
- }
200
188
List <Throwable > exceptions = new ArrayList <>(0 );
201
189
final IndexFieldDataCache cache = fieldDataCaches .remove (fieldName );
202
190
if (cache != null ) {
0 commit comments