|
18 | 18 | */ |
19 | 19 | package org.elasticsearch.search.lookup; |
20 | 20 |
|
| 21 | +import org.apache.logging.log4j.LogManager; |
21 | 22 | import org.apache.lucene.index.LeafReaderContext; |
22 | 23 | import org.elasticsearch.ExceptionsHelper; |
23 | 24 | import org.elasticsearch.common.Nullable; |
| 25 | +import org.elasticsearch.common.logging.DeprecationLogger; |
24 | 26 | import org.elasticsearch.index.fielddata.IndexFieldData; |
25 | 27 | import org.elasticsearch.index.fielddata.ScriptDocValues; |
26 | 28 | import org.elasticsearch.index.mapper.MappedFieldType; |
|
38 | 40 |
|
39 | 41 | public class LeafDocLookup implements Map<String, ScriptDocValues<?>> { |
40 | 42 |
|
| 43 | + private static final DeprecationLogger DEPRECATION_LOGGER |
| 44 | + = new DeprecationLogger(LogManager.getLogger(LeafDocLookup.class)); |
| 45 | + static final String TYPES_DEPRECATION_KEY = "type-field-doc-lookup"; |
| 46 | + static final String TYPES_DEPRECATION_MESSAGE = |
| 47 | + "[types removal] Looking up doc types in scripts is deprecated."; |
| 48 | + |
41 | 49 | private final Map<String, ScriptDocValues<?>> localCacheFieldData = new HashMap<>(4); |
42 | 50 |
|
43 | 51 | private final MapperService mapperService; |
@@ -72,6 +80,10 @@ public void setDocument(int docId) { |
72 | 80 |
|
73 | 81 | @Override |
74 | 82 | public ScriptDocValues<?> get(Object key) { |
| 83 | + // deprecate _type |
| 84 | + if ("_type".equals(key)) { |
| 85 | + DEPRECATION_LOGGER.deprecatedAndMaybeLog(TYPES_DEPRECATION_KEY, TYPES_DEPRECATION_MESSAGE); |
| 86 | + } |
75 | 87 | // assume its a string... |
76 | 88 | String fieldName = key.toString(); |
77 | 89 | ScriptDocValues<?> scriptValues = localCacheFieldData.get(fieldName); |
|
0 commit comments