@Test public void testAnyOnArrayLiteral() throws Exception { Reference ref = createReference("d", DataTypes.STRING); Literal stringArrayLiteral = Literal.newLiteral( new Object[] {new BytesRef("a"), new BytesRef("b"), new BytesRef("c")}, new ArrayType(DataTypes.STRING)); // col != ANY (1,2,3) Query neqQuery = convert(whereClause(AnyNeqOperator.NAME, ref, stringArrayLiteral)); assertThat(neqQuery, instanceOf(FilteredQuery.class)); assertThat(((FilteredQuery) neqQuery).getFilter(), instanceOf(BooleanFilter.class)); BooleanFilter filter = (BooleanFilter) ((FilteredQuery) neqQuery).getFilter(); assertThat(filter.toString(), is("BooleanFilter(-BooleanFilter(+d:a +d:b +d:c))")); // col like any (1,2,3) Query likeQuery = convert(whereClause(AnyLikeOperator.NAME, ref, stringArrayLiteral)); assertThat(likeQuery, instanceOf(BooleanQuery.class)); BooleanQuery likeBQuery = (BooleanQuery) likeQuery; assertThat(likeBQuery.clauses().size(), is(3)); for (int i = 0; i < 2; i++) { // like --> XConstantScoreQuery with regexp-filter Query filteredQuery = likeBQuery.clauses().get(i).getQuery(); assertThat(filteredQuery, instanceOf(XConstantScoreQuery.class)); assertThat(((XConstantScoreQuery) filteredQuery).getFilter(), instanceOf(RegexpFilter.class)); } // col not like any (1,2,3) Query notLikeQuery = convert(whereClause(AnyNotLikeOperator.NAME, ref, stringArrayLiteral)); assertThat(notLikeQuery, instanceOf(BooleanQuery.class)); BooleanQuery notLikeBQuery = (BooleanQuery) notLikeQuery; assertThat(notLikeBQuery.clauses(), hasSize(1)); BooleanClause clause = notLikeBQuery.clauses().get(0); assertThat(clause.getOccur(), is(BooleanClause.Occur.MUST_NOT)); assertThat(((BooleanQuery) clause.getQuery()).clauses(), hasSize(3)); for (BooleanClause innerClause : ((BooleanQuery) clause.getQuery()).clauses()) { assertThat(innerClause.getOccur(), is(BooleanClause.Occur.MUST)); assertThat(innerClause.getQuery(), instanceOf(XConstantScoreQuery.class)); assertThat( ((XConstantScoreQuery) innerClause.getQuery()).getFilter(), instanceOf(RegexpFilter.class)); } // col < any (1,2,3) Query ltQuery2 = convert(whereClause(AnyLtOperator.NAME, ref, stringArrayLiteral)); assertThat(ltQuery2, instanceOf(BooleanQuery.class)); BooleanQuery ltBQuery = (BooleanQuery) ltQuery2; assertThat(ltBQuery.toString(), is("(d:{* TO a} d:{* TO b} d:{* TO c})~1")); }