diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/engine/IndexEngine.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/engine/IndexEngine.java index 4de51a4c293..25e98e81e4a 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/engine/IndexEngine.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/engine/IndexEngine.java @@ -29,11 +29,5 @@ import org.elasticsearch.index.IndexComponent; */ public interface IndexEngine extends IndexComponent { - /** - * Are readers cloned on deletion? If this is the case, then some specific - * needs to be taken. - */ - boolean readerClonedOnDeletion(); - void close(); } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/engine/robin/RobinIndexEngine.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/engine/robin/RobinIndexEngine.java index defa199d590..8aff8ba501a 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/engine/robin/RobinIndexEngine.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/engine/robin/RobinIndexEngine.java @@ -41,13 +41,6 @@ public class RobinIndexEngine extends AbstractIndexComponent implements IndexEng super(index, indexSettings); } - /** - * With NRT, readers are cloned on deletions... . - */ - @Override public boolean readerClonedOnDeletion() { - return true; - } - @Override public void close() { } } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/ConstantScoreQueryParser.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/ConstantScoreQueryParser.java index e922ca0b837..43c545f85d5 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/ConstantScoreQueryParser.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/ConstantScoreQueryParser.java @@ -19,7 +19,6 @@ package org.elasticsearch.index.query.xcontent; -import org.apache.lucene.search.ConstantScoreQuery; import org.apache.lucene.search.DeletionAwareConstantScoreQuery; import org.apache.lucene.search.Filter; import org.apache.lucene.search.Query; @@ -77,19 +76,12 @@ public class ConstantScoreQueryParser extends AbstractIndexComponent implements throw new QueryParsingException(index, "[constant_score] requires 'filter' element"); } - // cache the filter if possible - Query query; + // cache the filter if possible needed if (cache) { - Filter nonCachedFilter = filter; filter = parseContext.cacheFilter(filter); - if (parseContext.indexEngine().readerClonedOnDeletion() && (filter != nonCachedFilter)) { - query = new DeletionAwareConstantScoreQuery(filter, true); - } else { - query = new ConstantScoreQuery(filter); - } - } else { - query = new ConstantScoreQuery(filter); } + + Query query = new DeletionAwareConstantScoreQuery(filter, true); query.setBoost(boost); return query; } diff --git a/modules/elasticsearch/src/test/java/org/elasticsearch/index/query/xcontent/SimpleIndexQueryParserTests.java b/modules/elasticsearch/src/test/java/org/elasticsearch/index/query/xcontent/SimpleIndexQueryParserTests.java index 70cc13e3271..ac4591ad79f 100644 --- a/modules/elasticsearch/src/test/java/org/elasticsearch/index/query/xcontent/SimpleIndexQueryParserTests.java +++ b/modules/elasticsearch/src/test/java/org/elasticsearch/index/query/xcontent/SimpleIndexQueryParserTests.java @@ -881,8 +881,8 @@ public class SimpleIndexQueryParserTests { @Test public void testConstantScoreQueryBuilder() throws IOException { IndexQueryParser queryParser = queryParser(); Query parsedQuery = queryParser.parse(constantScoreQuery(termFilter("name.last", "banon"))).query(); - assertThat(parsedQuery, instanceOf(ConstantScoreQuery.class)); - ConstantScoreQuery constantScoreQuery = (ConstantScoreQuery) parsedQuery; + assertThat(parsedQuery, instanceOf(DeletionAwareConstantScoreQuery.class)); + DeletionAwareConstantScoreQuery constantScoreQuery = (DeletionAwareConstantScoreQuery) parsedQuery; assertThat(((TermFilter) constantScoreQuery.getFilter()).getTerm(), equalTo(new Term("name.last", "banon"))); } @@ -890,8 +890,8 @@ public class SimpleIndexQueryParserTests { IndexQueryParser queryParser = queryParser(); String query = copyToStringFromClasspath("/org/elasticsearch/index/query/xcontent/constantScore-query.json"); Query parsedQuery = queryParser.parse(query).query(); - assertThat(parsedQuery, instanceOf(ConstantScoreQuery.class)); - ConstantScoreQuery constantScoreQuery = (ConstantScoreQuery) parsedQuery; + assertThat(parsedQuery, instanceOf(DeletionAwareConstantScoreQuery.class)); + DeletionAwareConstantScoreQuery constantScoreQuery = (DeletionAwareConstantScoreQuery) parsedQuery; assertThat(((TermFilter) constantScoreQuery.getFilter()).getTerm(), equalTo(new Term("name.last", "banon"))); }