private QueryBuilder createNumericFilter(String fieldName, SearchQuery.NumericOperator operator) { switch (operator.getType()) { case EQUALS: return boolQuery().filter(rangeQuery(fieldName).gte(operator.getValue()).lte(operator.getValue())); case GREATER_THAN: return boolQuery().filter(rangeQuery(fieldName).gte(operator.getValue())); case LESS_THAN: return boolQuery().filter(rangeQuery(fieldName).lte(operator.getValue())); default: throw new RuntimeException("A non existing numeric operator was triggered"); } }
private boolean matches(SearchQuery.ModSeqCriterion criterion, MailboxMessage message) throws UnsupportedSearchException { SearchQuery.NumericOperator operator = criterion.getOperator(); long modSeq = message.getModSeq(); long value = operator.getValue(); switch (operator.getType()) { case LESS_THAN: return modSeq < value; case GREATER_THAN: return modSeq > value; case EQUALS: return modSeq == value; default: throw new UnsupportedSearchException(); } }
private boolean matches(SearchQuery.SizeCriterion criterion, MailboxMessage message) throws UnsupportedSearchException { SearchQuery.NumericOperator operator = criterion.getOperator(); long size = message.getFullContentOctets(); long value = operator.getValue(); switch (operator.getType()) { case LESS_THAN: return size < value; case GREATER_THAN: return size > value; case EQUALS: return size == value; default: throw new UnsupportedSearchException(); } }
/** * Creates a filter for message size equal to the given value * * @param value * messages with size equal to this value will be selected by the * returned criterion * @return <code>Criterion</code>, not null */ public static Criterion sizeEquals(long value) { return new SizeCriterion(new NumericOperator(value, NumericComparator.EQUALS)); }
/** * Creates a filter for message size greater than the given value * * @param value * messages with size greater than this value will be selected by * the returned criterion * @return <code>Criterion</code>, not null */ public static Criterion sizeGreaterThan(long value) { return new SizeCriterion(new NumericOperator(value, NumericComparator.GREATER_THAN)); }
/** * Creates a filter for message mod-sequence equal to the given value * * @param value * messages with mod-sequence equal to this value will be * selected by the returned criterion * @return <code>Criterion</code>, not null */ public static Criterion modSeqEquals(long value) { return new ModSeqCriterion(new NumericOperator(value, NumericComparator.EQUALS)); }
/** * Creates a filter for message mod-sequence less than the given value * * @param value * messages with mod-sequence less than this value will be * selected by the returned criterion * @return <code>Criterion</code>, not null */ public static Criterion modSeqLessThan(long value) { return new ModSeqCriterion(new NumericOperator(value, NumericComparator.LESS_THAN)); }
/** * Creates a filter for message mod-sequence greater than the given value * * @param value * messages with mod-sequence greater than this value will be * selected by the returned criterion * @return <code>Criterion</code>, not null */ public static Criterion modSeqGreaterThan(long value) { return new ModSeqCriterion(new NumericOperator(value, NumericComparator.GREATER_THAN)); }
/** * Creates a filter for message size less than the given value * * @param value * messages with size less than this value will be selected by * the returned criterion * @return <code>Criterion</code>, not null */ public static Criterion sizeLessThan(long value) { return new SizeCriterion(new NumericOperator(value, NumericComparator.LESS_THAN)); }