public void testAnd() throws IOException {
IndexService indexService = createIndex("test", SINGLE_SHARD_SETTINGS, "type", "l", "type=long");
client().prepareIndex("test", "type").setSource("l", new long[] {7, 8}).get();
// And with fast clauses is fast
FilterBuilder filter = FilterBuilders.andFilter(FilterBuilders.termFilter("l", 7), FilterBuilders.termFilter("l", 8));
test(indexService, false, filter);
// If at least one clause is 'fast' and the other clauses supports random-access, it is still fast
filter = FilterBuilders.andFilter(FilterBuilders.termFilter("l", 7).cache(randomBoolean()), FilterBuilders.scriptFilter("doc['l'].value < 8"));
test(indexService, false, filter);
// However if all clauses are broken, the and is broken