Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 @SuppressWarnings("unchecked")
 private static BytesRef[] getBytesRefs(Collection values, TermBuilder termBuilder) {
   BytesRef[] terms = new BytesRef[values.size()];
   int i = 0;
   for (Object value : values) {
     terms[i] = termBuilder.term(value);
     i++;
   }
   return terms;
 }
Esempio n. 3
0
      @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);
      }