private TermsFilter termsFilter(String columnName, Literal arrayLiteral) { TermsFilter termsFilter; Object values = arrayLiteral.value(); if (values instanceof Collection) { termsFilter = new TermsFilter( columnName, getBytesRefs((Collection) values, TermBuilder.forType(arrayLiteral.valueType()))); } else { termsFilter = new TermsFilter( columnName, getBytesRefs((Object[]) values, TermBuilder.forType(arrayLiteral.valueType()))); } return termsFilter; }
@Override public Query apply(Function input, Context context) throws IOException { Tuple<Reference, Literal> tuple = prepare(input); if (tuple == null) { return null; } String field = tuple.v1().info().ident().columnIdent().fqn(); Literal literal = tuple.v2(); CollectionType dataType = ((CollectionType) literal.valueType()); Set values = (Set) literal.value(); DataType innerType = dataType.innerType(); BytesRef[] terms = getBytesRefs(values, TermBuilder.forType(innerType)); TermsFilter termsFilter = new TermsFilter(field, terms); return new FilteredQuery(Queries.newMatchAllQuery(), termsFilter); }