Ejemplo n.º 1
0
      @Override
      protected Query applyArrayLiteral(Reference reference, Literal arrayLiteral, Context context)
          throws IOException {
        //  col != ANY ([1,2,3]) --> not(col=1 and col=2 and col=3)
        String columnName = reference.info().ident().columnIdent().fqn();
        QueryBuilderHelper builder = QueryBuilderHelper.forType(reference.valueType());
        BooleanFilter filter = new BooleanFilter();

        BooleanFilter notFilter = new BooleanFilter();
        for (Object value : toIterable(arrayLiteral.value())) {
          notFilter.add(builder.eqFilter(columnName, value), BooleanClause.Occur.MUST);
        }
        filter.add(notFilter, BooleanClause.Occur.MUST_NOT);

        return new FilteredQuery(Queries.newMatchAllQuery(), filter);
      }
Ejemplo n.º 2
0
 private void buildTermsQuery(
     BooleanFilter booleanFilter,
     Object value,
     String columnName,
     QueryBuilderHelper builder) {
   if (value == null) {
     return;
   }
   if (value.getClass().isArray()) {
     Object[] array = (Object[]) value;
     for (Object o : array) {
       buildTermsQuery(booleanFilter, o, columnName, builder);
     }
   } else {
     booleanFilter.add(builder.eqFilter(columnName, value), BooleanClause.Occur.MUST);
   }
 }