Query DSL: query_string / field to use the optimized match_all query when using * (or *:*), closes #413.
This commit is contained in:
parent
504a5458c5
commit
d0bf743ab4
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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";
|
||||
|
|
Loading…
Reference in New Issue