diff --git a/modules/elasticsearch/src/main/java/org/apache/lucene/queryParser/MapperQueryParser.java b/modules/elasticsearch/src/main/java/org/apache/lucene/queryParser/MapperQueryParser.java index f5a178244fc..0a52bbdc40d 100644 --- a/modules/elasticsearch/src/main/java/org/apache/lucene/queryParser/MapperQueryParser.java +++ b/modules/elasticsearch/src/main/java/org/apache/lucene/queryParser/MapperQueryParser.java @@ -24,6 +24,7 @@ import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.MultiTermQuery; import org.apache.lucene.search.Query; import org.elasticsearch.common.lucene.Lucene; +import org.elasticsearch.common.lucene.search.Queries; import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.FieldMappers; import org.elasticsearch.index.mapper.MapperService; @@ -83,6 +84,10 @@ public class MapperQueryParser extends QueryParser { return super.newTermQuery(term); } + @Override protected Query newMatchAllDocsQuery() { + return Queries.MATCH_ALL_QUERY; + } + @Override public Query getFieldQuery(String field, String queryText) throws ParseException { currentMapper = null; if (parseContext.mapperService() != null) { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/search/Queries.java b/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/search/Queries.java index 9aa1fc66d5e..48a47304846 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/search/Queries.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/common/lucene/search/Queries.java @@ -29,12 +29,13 @@ import java.util.List; */ public class Queries { - public final static MatchAllDocsQuery MATCH_ALL_QUERY = new MatchAllDocsQuery(); + // We don't use MatchAllDocsQuery, its slower than the one below ... (much slower) + public final static Query MATCH_ALL_QUERY = new DeletionAwareConstantScoreQuery(new MatchAllDocsFilter(), true); /** * A match all docs filter. Note, requires no caching!. */ - public final static MatchAllDocsFilter MATCH_ALL_FILTER = new MatchAllDocsFilter(); + public final static Filter MATCH_ALL_FILTER = new MatchAllDocsFilter(); private final static Field disjuncts; diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/MatchAllQueryParser.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/MatchAllQueryParser.java index 1e8faa4c3c4..d03fe3b03d9 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/MatchAllQueryParser.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/query/xcontent/MatchAllQueryParser.java @@ -19,7 +19,6 @@ package org.elasticsearch.index.query.xcontent; -import org.apache.lucene.search.DeletionAwareConstantScoreQuery; import org.apache.lucene.search.MatchAllDocsQuery; import org.apache.lucene.search.Query; import org.elasticsearch.common.Strings; @@ -70,7 +69,7 @@ public class MatchAllQueryParser extends AbstractIndexComponent implements XCont } if (boost == 1.0f && normsField == null) { - return new DeletionAwareConstantScoreQuery(Queries.MATCH_ALL_FILTER, true); // no need to cache a MATCH ALL FILTER + return Queries.MATCH_ALL_QUERY; } MatchAllDocsQuery query = new MatchAllDocsQuery(normsField); diff --git a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/gateway/fs/FsMetaDataGatewayTests.java b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/gateway/fs/FsMetaDataGatewayTests.java index 2507b34c363..b27f9b74fb2 100644 --- a/modules/test/integration/src/test/java/org/elasticsearch/test/integration/gateway/fs/FsMetaDataGatewayTests.java +++ b/modules/test/integration/src/test/java/org/elasticsearch/test/integration/gateway/fs/FsMetaDataGatewayTests.java @@ -56,6 +56,7 @@ public class FsMetaDataGatewayTests extends AbstractNodesTests { closeNode("server1"); startNode("server1"); + Thread.sleep(500); try { client("server1").admin().indices().create(createIndexRequest("test")).actionGet(); assert false : "index should exists"; diff --git a/plugins/hadoop/src/test/java/org/elasticsearch/hadoop/gateway/HdfsGatewayTests.java b/plugins/hadoop/src/test/java/org/elasticsearch/hadoop/gateway/HdfsGatewayTests.java index 5f633489376..0434ff546ca 100644 --- a/plugins/hadoop/src/test/java/org/elasticsearch/hadoop/gateway/HdfsGatewayTests.java +++ b/plugins/hadoop/src/test/java/org/elasticsearch/hadoop/gateway/HdfsGatewayTests.java @@ -77,12 +77,13 @@ public class HdfsGatewayTests { node.close(); } - @Test public void testHdfsGateway() { + @Test public void testHdfsGateway() throws Exception { // first, test meta data CreateIndexResponse createIndexResponse = node.client().admin().indices().create(createIndexRequest("test")).actionGet(); assertThat(createIndexResponse.acknowledged(), equalTo(true)); node.close(); node = buildNode().start(); + Thread.sleep(500); try { node.client().admin().indices().create(createIndexRequest("test")).actionGet(); assert false : "index should exists";