Skip to content

Commit 67a709d

Browse files
committed
Merge branch 'master' into lazy-seq-no-bit-sets
* master: Remove checkpoint tracker bit sets setting Fix stable BWC branch detection logic Fix logic detecting unreleased versions Enhances exists queries to reduce need for `_field_names` (elastic#26930) Added new terms_set query Set request body to required to reflect the code base (elastic#27188) Update Docker docs for 6.0.0-rc2 (elastic#27166) Add version 6.0.0 Docs: restore now fails if it encounters incompatible settings (elastic#26933) Convert index blocks to cluster block exceptions (elastic#27050) [DOCS] Link remote info API in Cross Cluster Search docs page Fix Laplace scorer to multiply by alpha (and not add) (elastic#27125) [DOCS] Clarify migrate guide and search request validation Raise IllegalArgumentException if query validation failed (elastic#26811) prevent duplicate fields when mixing parent and root nested includes (elastic#27072) TopHitsAggregator must propagate calls to `setScorer`. (elastic#27138)
2 parents f4f0dae + 90d6317 commit 67a709d

File tree

88 files changed

+3275
-362
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+3275
-362
lines changed

core/src/main/java/org/elasticsearch/Version.java

+5
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ public class Version implements Comparable<Version> {
118118
public static final int V_6_0_0_rc2_ID = 6000052;
119119
public static final Version V_6_0_0_rc2 =
120120
new Version(V_6_0_0_rc2_ID, org.apache.lucene.util.Version.LUCENE_7_0_1);
121+
public static final int V_6_0_0_ID = 6000099;
122+
public static final Version V_6_0_0 =
123+
new Version(V_6_0_0_ID, org.apache.lucene.util.Version.LUCENE_7_0_1);
121124
public static final int V_6_1_0_ID = 6010099;
122125
public static final Version V_6_1_0 =
123126
new Version(V_6_1_0_ID, org.apache.lucene.util.Version.LUCENE_7_1_0);
@@ -143,6 +146,8 @@ public static Version fromId(int id) {
143146
return V_7_0_0_alpha1;
144147
case V_6_1_0_ID:
145148
return V_6_1_0;
149+
case V_6_0_0_ID:
150+
return V_6_0_0;
146151
case V_6_0_0_rc2_ID:
147152
return V_6_0_0_rc2;
148153
case V_6_0_0_beta2_ID:

core/src/main/java/org/elasticsearch/action/admin/indices/template/delete/TransportDeleteIndexTemplateAction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ protected DeleteIndexTemplateResponse newResponse() {
6262

6363
@Override
6464
protected ClusterBlockException checkBlock(DeleteIndexTemplateRequest request, ClusterState state) {
65-
return state.blocks().indexBlockedException(ClusterBlockLevel.METADATA_WRITE, "");
65+
return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE);
6666
}
6767

6868
@Override

core/src/main/java/org/elasticsearch/action/admin/indices/template/put/TransportPutIndexTemplateAction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ protected PutIndexTemplateResponse newResponse() {
6666

6767
@Override
6868
protected ClusterBlockException checkBlock(PutIndexTemplateRequest request, ClusterState state) {
69-
return state.blocks().indexBlockedException(ClusterBlockLevel.METADATA_WRITE, "");
69+
return state.blocks().globalBlockedException(ClusterBlockLevel.METADATA_WRITE);
7070
}
7171

7272
@Override

core/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java

-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ public final class IndexScopedSettings extends AbstractScopedSettings {
120120
IndexSettings.QUERY_STRING_LENIENT_SETTING,
121121
IndexSettings.ALLOW_UNMAPPED,
122122
IndexSettings.INDEX_CHECK_ON_STARTUP,
123-
LocalCheckpointTracker.SETTINGS_BIT_ARRAYS_SIZE,
124123
IndexSettings.MAX_REFRESH_LISTENERS_PER_SHARD,
125124
IndexSettings.MAX_SLICES_PER_SCROLL,
126125
ShardsLimitAllocationDecider.INDEX_TOTAL_SHARDS_PER_NODE_SETTING,

core/src/main/java/org/elasticsearch/index/mapper/BinaryFieldMapper.java

+18
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@
2020
package org.elasticsearch.index.mapper;
2121

2222
import com.carrotsearch.hppc.ObjectArrayList;
23+
2324
import org.apache.lucene.document.Field;
2425
import org.apache.lucene.index.IndexOptions;
2526
import org.apache.lucene.index.IndexableField;
27+
import org.apache.lucene.index.Term;
28+
import org.apache.lucene.search.DocValuesFieldExistsQuery;
2629
import org.apache.lucene.search.Query;
30+
import org.apache.lucene.search.TermQuery;
2731
import org.apache.lucene.store.ByteArrayDataOutput;
2832
import org.apache.lucene.util.BytesRef;
2933
import org.elasticsearch.ElasticsearchException;
@@ -126,6 +130,15 @@ public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
126130
return new BytesBinaryDVIndexFieldData.Builder();
127131
}
128132

133+
@Override
134+
public Query existsQuery(QueryShardContext context) {
135+
if (hasDocValues()) {
136+
return new DocValuesFieldExistsQuery(name());
137+
} else {
138+
return new TermQuery(new Term(FieldNamesFieldMapper.NAME, name()));
139+
}
140+
}
141+
129142
@Override
130143
public Query termQuery(Object value, QueryShardContext context) {
131144
throw new QueryShardException(context, "Binary fields do not support searching");
@@ -165,6 +178,11 @@ protected void parseCreateField(ParseContext context, List<IndexableField> field
165178
} else {
166179
field.add(value);
167180
}
181+
} else {
182+
// Only add an entry to the field names field if the field is stored
183+
// but has no doc values so exists query will work on a field with
184+
// no doc values
185+
createFieldNamesField(context, fields);
168186
}
169187

170188
}

core/src/main/java/org/elasticsearch/index/mapper/BooleanFieldMapper.java

+14
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
import org.apache.lucene.document.SortedNumericDocValuesField;
2424
import org.apache.lucene.index.IndexOptions;
2525
import org.apache.lucene.index.IndexableField;
26+
import org.apache.lucene.index.Term;
27+
import org.apache.lucene.search.DocValuesFieldExistsQuery;
2628
import org.apache.lucene.search.Query;
29+
import org.apache.lucene.search.TermQuery;
2730
import org.apache.lucene.search.TermRangeQuery;
2831
import org.apache.lucene.util.BytesRef;
2932
import org.elasticsearch.Version;
@@ -136,6 +139,15 @@ public String typeName() {
136139
return CONTENT_TYPE;
137140
}
138141

142+
@Override
143+
public Query existsQuery(QueryShardContext context) {
144+
if (hasDocValues()) {
145+
return new DocValuesFieldExistsQuery(name());
146+
} else {
147+
return new TermQuery(new Term(FieldNamesFieldMapper.NAME, name()));
148+
}
149+
}
150+
139151
@Override
140152
public Boolean nullValue() {
141153
return (Boolean)super.nullValue();
@@ -253,6 +265,8 @@ protected void parseCreateField(ParseContext context, List<IndexableField> field
253265
}
254266
if (fieldType().hasDocValues()) {
255267
fields.add(new SortedNumericDocValuesField(fieldType().name(), value ? 1 : 0));
268+
} else {
269+
createFieldNamesField(context, fields);
256270
}
257271
}
258272

core/src/main/java/org/elasticsearch/index/mapper/CompletionFieldMapper.java

+14
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import org.apache.lucene.codecs.PostingsFormat;
2222
import org.apache.lucene.index.IndexableField;
2323
import org.apache.lucene.index.Term;
24+
import org.apache.lucene.search.Query;
25+
import org.apache.lucene.search.TermQuery;
2426
import org.apache.lucene.search.suggest.document.Completion50PostingsFormat;
2527
import org.apache.lucene.search.suggest.document.CompletionAnalyzer;
2628
import org.apache.lucene.search.suggest.document.CompletionQuery;
@@ -40,11 +42,13 @@
4042
import org.elasticsearch.common.xcontent.XContentParser.Token;
4143
import org.elasticsearch.index.analysis.AnalyzerScope;
4244
import org.elasticsearch.index.analysis.NamedAnalyzer;
45+
import org.elasticsearch.index.query.QueryShardContext;
4346
import org.elasticsearch.search.suggest.completion.CompletionSuggester;
4447
import org.elasticsearch.search.suggest.completion.context.ContextMapping;
4548
import org.elasticsearch.search.suggest.completion.context.ContextMappings;
4649

4750
import java.io.IOException;
51+
import java.util.ArrayList;
4852
import java.util.Collections;
4953
import java.util.HashMap;
5054
import java.util.HashSet;
@@ -257,6 +261,11 @@ public static synchronized PostingsFormat postingsFormat() {
257261
return postingsFormat;
258262
}
259263

264+
@Override
265+
public Query existsQuery(QueryShardContext context) {
266+
return new TermQuery(new Term(FieldNamesFieldMapper.NAME, name()));
267+
}
268+
260269
/**
261270
* Completion prefix query
262271
*/
@@ -456,6 +465,11 @@ public Mapper parse(ParseContext context) throws IOException {
456465
context.doc().add(new SuggestField(fieldType().name(), input, metaData.weight));
457466
}
458467
}
468+
List<IndexableField> fields = new ArrayList<>(1);
469+
createFieldNamesField(context, fields);
470+
for (IndexableField field : fields) {
471+
context.doc().add(field);
472+
}
459473
multiFields.parse(this, context);
460474
return null;
461475
}

core/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java

+14
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@
2626
import org.apache.lucene.index.IndexReader;
2727
import org.apache.lucene.index.IndexableField;
2828
import org.apache.lucene.index.PointValues;
29+
import org.apache.lucene.index.Term;
2930
import org.apache.lucene.search.BoostQuery;
31+
import org.apache.lucene.search.DocValuesFieldExistsQuery;
3032
import org.apache.lucene.search.IndexOrDocValuesQuery;
3133
import org.apache.lucene.search.Query;
34+
import org.apache.lucene.search.TermQuery;
3235
import org.apache.lucene.util.BytesRef;
3336
import org.elasticsearch.Version;
3437
import org.elasticsearch.common.Explicit;
@@ -245,6 +248,15 @@ long parse(String value) {
245248
return dateTimeFormatter().parser().parseMillis(value);
246249
}
247250

251+
@Override
252+
public Query existsQuery(QueryShardContext context) {
253+
if (hasDocValues()) {
254+
return new DocValuesFieldExistsQuery(name());
255+
} else {
256+
return new TermQuery(new Term(FieldNamesFieldMapper.NAME, name()));
257+
}
258+
}
259+
248260
@Override
249261
public Query termQuery(Object value, @Nullable QueryShardContext context) {
250262
Query query = rangeQuery(value, value, true, true, ShapeRelation.INTERSECTS, null, null, context);
@@ -451,6 +463,8 @@ protected void parseCreateField(ParseContext context, List<IndexableField> field
451463
}
452464
if (fieldType().hasDocValues()) {
453465
fields.add(new SortedNumericDocValuesField(fieldType().name(), timestamp));
466+
} else if (fieldType().stored() || fieldType().indexOptions() != IndexOptions.NONE) {
467+
createFieldNamesField(context, fields);
454468
}
455469
if (fieldType().stored()) {
456470
fields.add(new StoredField(fieldType().name(), timestamp));

core/src/main/java/org/elasticsearch/index/mapper/FieldMapper.java

+12
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.carrotsearch.hppc.cursors.ObjectCursor;
2323
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
2424

25+
import org.apache.lucene.document.Field;
2526
import org.apache.lucene.document.FieldType;
2627
import org.apache.lucene.index.IndexOptions;
2728
import org.apache.lucene.index.IndexableField;
@@ -33,6 +34,7 @@
3334
import org.elasticsearch.common.settings.Settings;
3435
import org.elasticsearch.common.xcontent.XContentBuilder;
3536
import org.elasticsearch.index.analysis.NamedAnalyzer;
37+
import org.elasticsearch.index.mapper.FieldNamesFieldMapper.FieldNamesFieldType;
3638
import org.elasticsearch.index.similarity.SimilarityProvider;
3739
import org.elasticsearch.index.similarity.SimilarityService;
3840

@@ -285,6 +287,16 @@ public Mapper parse(ParseContext context) throws IOException {
285287
*/
286288
protected abstract void parseCreateField(ParseContext context, List<IndexableField> fields) throws IOException;
287289

290+
protected void createFieldNamesField(ParseContext context, List<IndexableField> fields) {
291+
FieldNamesFieldType fieldNamesFieldType = (FieldNamesFieldMapper.FieldNamesFieldType) context.docMapper()
292+
.metadataMapper(FieldNamesFieldMapper.class).fieldType();
293+
if (fieldNamesFieldType != null && fieldNamesFieldType.isEnabled()) {
294+
for (String fieldName : FieldNamesFieldMapper.extractFieldNames(fieldType().name())) {
295+
fields.add(new Field(FieldNamesFieldMapper.NAME, fieldName, fieldNamesFieldType));
296+
}
297+
}
298+
}
299+
288300
@Override
289301
public Iterator<Mapper> iterator() {
290302
return multiFields.iterator();

core/src/main/java/org/elasticsearch/index/mapper/FieldNamesFieldMapper.java

+18-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
import org.apache.lucene.index.IndexOptions;
2424
import org.apache.lucene.index.IndexableField;
2525
import org.apache.lucene.search.Query;
26+
import org.elasticsearch.Version;
27+
import org.elasticsearch.cluster.metadata.IndexMetaData;
28+
import org.elasticsearch.common.logging.DeprecationLogger;
29+
import org.elasticsearch.common.logging.ESLoggerFactory;
2630
import org.elasticsearch.common.lucene.Lucene;
2731
import org.elasticsearch.common.settings.Settings;
2832
import org.elasticsearch.common.xcontent.XContentBuilder;
@@ -44,6 +48,9 @@
4448
*/
4549
public class FieldNamesFieldMapper extends MetadataFieldMapper {
4650

51+
private static final DeprecationLogger DEPRECATION_LOGGER = new DeprecationLogger(
52+
ESLoggerFactory.getLogger(FieldNamesFieldMapper.class));
53+
4754
public static final String NAME = "_field_names";
4855

4956
public static final String CONTENT_TYPE = "_field_names";
@@ -178,11 +185,18 @@ public boolean isEnabled() {
178185
return enabled;
179186
}
180187

188+
@Override
189+
public Query existsQuery(QueryShardContext context) {
190+
throw new UnsupportedOperationException("Cannot run exists query on _field_names");
191+
}
192+
181193
@Override
182194
public Query termQuery(Object value, QueryShardContext context) {
183195
if (isEnabled() == false) {
184196
throw new IllegalStateException("Cannot run [exists] queries if the [_field_names] field is disabled");
185197
}
198+
DEPRECATION_LOGGER.deprecated(
199+
"terms query on the _field_names field is deprecated and will be removed, use exists query instead");
186200
return super.termQuery(value, context);
187201
}
188202
}
@@ -206,12 +220,14 @@ public void preParse(ParseContext context) throws IOException {
206220

207221
@Override
208222
public void postParse(ParseContext context) throws IOException {
209-
super.parse(context);
223+
if (context.indexSettings().getAsVersion(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT).before(Version.V_6_1_0)) {
224+
super.parse(context);
225+
}
210226
}
211227

212228
@Override
213229
public Mapper parse(ParseContext context) throws IOException {
214-
// we parse in post parse
230+
// Adding values to the _field_names field is handled by the mappers for each field type
215231
return null;
216232
}
217233

core/src/main/java/org/elasticsearch/index/mapper/GeoPointFieldMapper.java

+19
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
import org.apache.lucene.document.StoredField;
2424
import org.apache.lucene.index.IndexOptions;
2525
import org.apache.lucene.index.IndexableField;
26+
import org.apache.lucene.index.Term;
27+
import org.apache.lucene.search.DocValuesFieldExistsQuery;
2628
import org.apache.lucene.search.Query;
29+
import org.apache.lucene.search.TermQuery;
2730
import org.elasticsearch.ElasticsearchParseException;
2831
import org.elasticsearch.common.Explicit;
2932
import org.elasticsearch.common.geo.GeoPoint;
@@ -37,6 +40,7 @@
3740
import org.elasticsearch.index.query.QueryShardException;
3841

3942
import java.io.IOException;
43+
import java.util.ArrayList;
4044
import java.util.Iterator;
4145
import java.util.List;
4246
import java.util.Map;
@@ -180,6 +184,15 @@ public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
180184
return new AbstractLatLonPointDVIndexFieldData.Builder();
181185
}
182186

187+
@Override
188+
public Query existsQuery(QueryShardContext context) {
189+
if (hasDocValues()) {
190+
return new DocValuesFieldExistsQuery(name());
191+
} else {
192+
return new TermQuery(new Term(FieldNamesFieldMapper.NAME, name()));
193+
}
194+
}
195+
183196
@Override
184197
public Query termQuery(Object value, QueryShardContext context) {
185198
throw new QueryShardException(context, "Geo fields do not support exact searching, use dedicated geo queries instead: ["
@@ -207,6 +220,12 @@ protected void parse(ParseContext context, GeoPoint point) throws IOException {
207220
}
208221
if (fieldType.hasDocValues()) {
209222
context.doc().add(new LatLonDocValuesField(fieldType().name(), point.lat(), point.lon()));
223+
} else if (fieldType().stored() || fieldType().indexOptions() != IndexOptions.NONE) {
224+
List<IndexableField> fields = new ArrayList<>(1);
225+
createFieldNamesField(context, fields);
226+
for (IndexableField field : fields) {
227+
context.doc().add(field);
228+
}
210229
}
211230
// if the mapping contains multifields then use the geohash string
212231
if (multiFields.iterator().hasNext()) {

0 commit comments

Comments
 (0)