Skip to content

Commit 835a81c

Browse files
committed
always use deletion aware constant score
1 parent b7eacc3 commit 835a81c

File tree

4 files changed

+7
-28
lines changed

4 files changed

+7
-28
lines changed

modules/elasticsearch/src/main/java/org/elasticsearch/index/engine/IndexEngine.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,5 @@
2929
*/
3030
public interface IndexEngine extends IndexComponent {
3131

32-
/**
33-
* Are readers cloned on deletion? If this is the case, then some specific
34-
* needs to be taken.
35-
*/
36-
boolean readerClonedOnDeletion();
37-
3832
void close();
3933
}

modules/elasticsearch/src/main/java/org/elasticsearch/index/engine/robin/RobinIndexEngine.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,6 @@ public RobinIndexEngine(Index index) {
4141
super(index, indexSettings);
4242
}
4343

44-
/**
45-
* With NRT, readers are cloned on deletions... .
46-
*/
47-
@Override public boolean readerClonedOnDeletion() {
48-
return true;
49-
}
50-
5144
@Override public void close() {
5245
}
5346
}

modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/ConstantScoreQueryParser.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
package org.elasticsearch.index.query.xcontent;
2121

22-
import org.apache.lucene.search.ConstantScoreQuery;
2322
import org.apache.lucene.search.DeletionAwareConstantScoreQuery;
2423
import org.apache.lucene.search.Filter;
2524
import org.apache.lucene.search.Query;
@@ -77,19 +76,12 @@ public class ConstantScoreQueryParser extends AbstractIndexComponent implements
7776
throw new QueryParsingException(index, "[constant_score] requires 'filter' element");
7877
}
7978

80-
// cache the filter if possible
81-
Query query;
79+
// cache the filter if possible needed
8280
if (cache) {
83-
Filter nonCachedFilter = filter;
8481
filter = parseContext.cacheFilter(filter);
85-
if (parseContext.indexEngine().readerClonedOnDeletion() && (filter != nonCachedFilter)) {
86-
query = new DeletionAwareConstantScoreQuery(filter, true);
87-
} else {
88-
query = new ConstantScoreQuery(filter);
89-
}
90-
} else {
91-
query = new ConstantScoreQuery(filter);
9282
}
83+
84+
Query query = new DeletionAwareConstantScoreQuery(filter, true);
9385
query.setBoost(boost);
9486
return query;
9587
}

modules/elasticsearch/src/test/java/org/elasticsearch/index/query/xcontent/SimpleIndexQueryParserTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -881,17 +881,17 @@ private XContentIndexQueryParser queryParser() throws IOException {
881881
@Test public void testConstantScoreQueryBuilder() throws IOException {
882882
IndexQueryParser queryParser = queryParser();
883883
Query parsedQuery = queryParser.parse(constantScoreQuery(termFilter("name.last", "banon"))).query();
884-
assertThat(parsedQuery, instanceOf(ConstantScoreQuery.class));
885-
ConstantScoreQuery constantScoreQuery = (ConstantScoreQuery) parsedQuery;
884+
assertThat(parsedQuery, instanceOf(DeletionAwareConstantScoreQuery.class));
885+
DeletionAwareConstantScoreQuery constantScoreQuery = (DeletionAwareConstantScoreQuery) parsedQuery;
886886
assertThat(((TermFilter) constantScoreQuery.getFilter()).getTerm(), equalTo(new Term("name.last", "banon")));
887887
}
888888

889889
@Test public void testConstantScoreQuery() throws IOException {
890890
IndexQueryParser queryParser = queryParser();
891891
String query = copyToStringFromClasspath("/org/elasticsearch/index/query/xcontent/constantScore-query.json");
892892
Query parsedQuery = queryParser.parse(query).query();
893-
assertThat(parsedQuery, instanceOf(ConstantScoreQuery.class));
894-
ConstantScoreQuery constantScoreQuery = (ConstantScoreQuery) parsedQuery;
893+
assertThat(parsedQuery, instanceOf(DeletionAwareConstantScoreQuery.class));
894+
DeletionAwareConstantScoreQuery constantScoreQuery = (DeletionAwareConstantScoreQuery) parsedQuery;
895895
assertThat(((TermFilter) constantScoreQuery.getFilter()).getTerm(), equalTo(new Term("name.last", "banon")));
896896
}
897897

0 commit comments

Comments
 (0)