Skip to content

Commit ebc4e8d

Browse files
rjernstGurkan Kaymak
authored andcommitted
Remove 6.0 version constant uses (elastic#41965)
This commit removes all uses of the 6.0 version constants, since master no longer needs to know about them.
1 parent 401622e commit ebc4e8d

File tree

64 files changed

+106
-1024
lines changed

Some content is hidden

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

64 files changed

+106
-1024
lines changed

client/rest-high-level/src/test/java/org/elasticsearch/client/core/MainResponseTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ protected org.elasticsearch.action.main.MainResponse createServerTestInstance()
3838
ClusterName clusterName = new ClusterName(randomAlphaOfLength(10));
3939
String nodeName = randomAlphaOfLength(10);
4040
final String date = new Date(randomNonNegativeLong()).toString();
41-
Version version = VersionUtils.randomVersionBetween(random(), Version.V_6_0_1, Version.CURRENT);
41+
Version version = VersionUtils.randomIndexCompatibleVersion(random());
4242
Build build = new Build(
4343
Build.Flavor.UNKNOWN, Build.Type.UNKNOWN, randomAlphaOfLength(8), date, randomBoolean(),
4444
version.toString()

modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ Query percolateQuery(String name, PercolateQuery.QueryStore queryStore, List<Byt
261261
}
262262
Query filter = null;
263263
if (excludeNestedDocuments) {
264-
filter = Queries.newNonNestedFilter(indexVersion);
264+
filter = Queries.newNonNestedFilter();
265265
}
266266
return new PercolateQuery(name, queryStore, documents, candidateQuery, searcher, filter, verifiedMatchesQuery);
267267
}

modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorMatchedSlotSubFetchPhase.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.apache.lucene.search.Weight;
3131
import org.apache.lucene.util.BitSet;
3232
import org.apache.lucene.util.BitSetIterator;
33-
import org.elasticsearch.Version;
3433
import org.elasticsearch.common.document.DocumentField;
3534
import org.elasticsearch.common.lucene.search.Queries;
3635
import org.elasticsearch.search.SearchHit;
@@ -73,8 +72,7 @@ static void innerHitsExecute(Query mainQuery,
7372
for (PercolateQuery percolateQuery : percolateQueries) {
7473
String fieldName = singlePercolateQuery ? FIELD_NAME_PREFIX : FIELD_NAME_PREFIX + "_" + percolateQuery.getName();
7574
IndexSearcher percolatorIndexSearcher = percolateQuery.getPercolatorIndexSearcher();
76-
Query nonNestedQuery = Queries.newNonNestedFilter(Version.CURRENT);
77-
Weight weight = percolatorIndexSearcher.createWeight(percolatorIndexSearcher.rewrite(nonNestedQuery),
75+
Weight weight = percolatorIndexSearcher.createWeight(percolatorIndexSearcher.rewrite(Queries.newNonNestedFilter()),
7876
ScoreMode.COMPLETE_NO_SCORES, 1f);
7977
Scorer s = weight.scorer(percolatorIndexSearcher.getIndexReader().leaves().get(0));
8078
int memoryIndexMaxDoc = percolatorIndexSearcher.getIndexReader().maxDoc();

modules/percolator/src/test/java/org/elasticsearch/percolator/PercolatorFieldMapperTests.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -399,26 +399,6 @@ public void testCreateCandidateQuery() throws Exception {
399399
assertThat(t.v1().clauses().get(2).getQuery().toString(), containsString(fieldName + ".extraction_result:failed"));
400400
}
401401

402-
public void testCreateCandidateQuery_oldIndex() throws Exception {
403-
addQueryFieldMappings();
404-
405-
MemoryIndex memoryIndex = new MemoryIndex(false);
406-
memoryIndex.addField("field1", "value1", new WhitespaceAnalyzer());
407-
IndexReader indexReader = memoryIndex.createSearcher().getIndexReader();
408-
409-
Tuple<BooleanQuery, Boolean> t = fieldType.createCandidateQuery(indexReader, Version.CURRENT);
410-
assertTrue(t.v2());
411-
assertEquals(2, t.v1().clauses().size());
412-
assertThat(t.v1().clauses().get(0).getQuery(), instanceOf(CoveringQuery.class));
413-
assertThat(t.v1().clauses().get(1).getQuery(), instanceOf(TermQuery.class));
414-
415-
t = fieldType.createCandidateQuery(indexReader, Version.V_6_0_0);
416-
assertTrue(t.v2());
417-
assertEquals(2, t.v1().clauses().size());
418-
assertThat(t.v1().clauses().get(0).getQuery(), instanceOf(TermInSetQuery.class));
419-
assertThat(t.v1().clauses().get(1).getQuery(), instanceOf(TermQuery.class));
420-
}
421-
422402
public void testExtractTermsAndRanges_numberFields() throws Exception {
423403
addQueryFieldMappings();
424404

modules/percolator/src/test/java/org/elasticsearch/percolator/QueryAnalyzerTests.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,6 @@ public void testExtractQueryMetadata_booleanQueryWithMustNot() {
333333
assertThat(result.verified, is(false));
334334
assertThat(result.minimumShouldMatch, equalTo(0));
335335
assertTermsEqual(result.extractions);
336-
337-
result = analyze(booleanQuery, Version.CURRENT);
338-
assertThat(result.matchAllDocs, is(true));
339-
assertThat(result.verified, is(false));
340-
assertThat(result.minimumShouldMatch, equalTo(0));
341-
assertTermsEqual(result.extractions);
342336
}
343337

344338
public void testExactMatch_booleanQuery() {

rest-api-spec/src/main/resources/rest-api-spec/test/search/10_source_filtering.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -165,20 +165,6 @@ setup:
165165
docvalue_fields: [ "count" ]
166166
- match: { hits.hits.0.fields.count: [1] }
167167

168-
---
169-
"docvalue_fields with default format":
170-
- skip:
171-
features: warnings
172-
- do:
173-
warnings:
174-
- "[use_field_mapping] is a special format that was only used to ease the transition to 7.x. It has become the default and shouldn't be set explicitly anymore."
175-
search:
176-
body:
177-
docvalue_fields:
178-
- field: "count"
179-
format: "use_field_mapping"
180-
- match: { hits.hits.0.fields.count: [1] }
181-
182168
---
183169
"docvalue_fields with explicit format":
184170

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ public class Version implements Comparable<Version>, ToXContentFragment {
4646
*/
4747
public static final int V_EMPTY_ID = 0;
4848
public static final Version V_EMPTY = new Version(V_EMPTY_ID, org.apache.lucene.util.Version.LATEST);
49-
public static final int V_6_0_0_ID = 6000099;
50-
public static final Version V_6_0_0 =
51-
new Version(V_6_0_0_ID, org.apache.lucene.util.Version.LUCENE_7_0_1);
52-
public static final int V_6_0_1_ID = 6000199;
53-
public static final Version V_6_0_1 =
54-
new Version(V_6_0_1_ID, org.apache.lucene.util.Version.LUCENE_7_0_1);
5549
public static final int V_6_1_0_ID = 6010099;
5650
public static final Version V_6_1_0 = new Version(V_6_1_0_ID, org.apache.lucene.util.Version.LUCENE_7_1_0);
5751
public static final int V_6_1_1_ID = 6010199;
@@ -212,10 +206,6 @@ public static Version fromId(int id) {
212206
return V_6_1_1;
213207
case V_6_1_0_ID:
214208
return V_6_1_0;
215-
case V_6_0_1_ID:
216-
return V_6_0_1;
217-
case V_6_0_0_ID:
218-
return V_6_0_0;
219209
case V_EMPTY_ID:
220210
return V_EMPTY;
221211
default:

server/src/main/java/org/elasticsearch/common/lucene/search/Queries.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.apache.lucene.search.Query;
3232
import org.apache.lucene.util.BytesRef;
3333
import org.elasticsearch.ElasticsearchException;
34-
import org.elasticsearch.Version;
3534
import org.elasticsearch.common.Nullable;
3635
import org.elasticsearch.index.mapper.SeqNoFieldMapper;
3736
import org.elasticsearch.index.mapper.TypeFieldMapper;
@@ -72,17 +71,9 @@ public static Query newNestedFilter() {
7271

7372
/**
7473
* Creates a new non-nested docs query
75-
* @param indexVersionCreated the index version created since newer indices can identify a parent field more efficiently
7674
*/
77-
public static Query newNonNestedFilter(Version indexVersionCreated) {
78-
if (indexVersionCreated.onOrAfter(Version.V_6_1_0)) {
79-
return new DocValuesFieldExistsQuery(SeqNoFieldMapper.PRIMARY_TERM_NAME);
80-
} else {
81-
return new BooleanQuery.Builder()
82-
.add(new MatchAllDocsQuery(), Occur.FILTER)
83-
.add(newNestedFilter(), Occur.MUST_NOT)
84-
.build();
85-
}
75+
public static Query newNonNestedFilter() {
76+
return new DocValuesFieldExistsQuery(SeqNoFieldMapper.PRIMARY_TERM_NAME);
8677
}
8778

8879
public static BooleanQuery filtered(@Nullable Query query, @Nullable Query filter) {

server/src/main/java/org/elasticsearch/index/cache/bitset/BitsetFilterCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public IndexWarmer.TerminationHandle warmReader(final IndexShard indexShard, fin
251251
}
252252

253253
if (hasNested) {
254-
warmUp.add(Queries.newNonNestedFilter(indexSettings.getIndexVersionCreated()));
254+
warmUp.add(Queries.newNonNestedFilter());
255255
}
256256

257257
final CountDownLatch latch = new CountDownLatch(searcher.reader().leaves().size() * warmUp.size());

server/src/main/java/org/elasticsearch/index/mapper/TypeFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public Query termsQuery(List<?> values, QueryShardContext context) {
140140
.anyMatch(indexType::equals)) {
141141
if (context.getMapperService().hasNested()) {
142142
// type filters are expected not to match nested docs
143-
return Queries.newNonNestedFilter(context.indexVersionCreated());
143+
return Queries.newNonNestedFilter();
144144
} else {
145145
return new MatchAllDocsQuery();
146146
}

0 commit comments

Comments
 (0)