|
|
@@ -20,6 +20,8 @@
|
|
|
package org.elasticsearch.index.query;
|
|
|
|
|
|
import org.apache.lucene.index.Term;
|
|
|
+import org.apache.lucene.search.MatchAllDocsQuery;
|
|
|
+import org.apache.lucene.search.MatchNoDocsQuery;
|
|
|
import org.apache.lucene.search.Query;
|
|
|
import org.apache.lucene.search.WildcardQuery;
|
|
|
import org.elasticsearch.common.ParsingException;
|
|
|
@@ -136,4 +138,20 @@ public class WildcardQueryBuilderTests extends AbstractQueryTestCase<WildcardQue
|
|
|
assertEquals(expected, query);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public void testIndexWildcard() throws IOException {
|
|
|
+ assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);
|
|
|
+
|
|
|
+ QueryShardContext context = createShardContext();
|
|
|
+ String index = context.getFullyQualifiedIndexName();
|
|
|
+
|
|
|
+ Query query = new WildcardQueryBuilder("_index", index).doToQuery(context);
|
|
|
+ assertThat(query instanceof MatchAllDocsQuery, equalTo(true));
|
|
|
+
|
|
|
+ query = new WildcardQueryBuilder("_index", index + "*").doToQuery(context);
|
|
|
+ assertThat(query instanceof MatchAllDocsQuery, equalTo(true));
|
|
|
+
|
|
|
+ query = new WildcardQueryBuilder("_index", "index_" + index + "*").doToQuery(context);
|
|
|
+ assertThat(query instanceof MatchNoDocsQuery, equalTo(true));
|
|
|
+ }
|
|
|
}
|