public static RegexOptions randomRegexOptions() { final RegexOptions.Builder builder = RegexOptions.builder(); maybeSet(builder::setMaxDeterminizedStates, randomIntBetween(1, 1000)); StringBuilder sb = new StringBuilder(); for (RegexpFlag regexpFlag : RegexpFlag.values()) { if (randomBoolean()) { if (sb.length() != 0) { sb.append("|"); } sb.append(regexpFlag.name()); } } maybeSet(builder::setFlags, sb.toString()); return builder.build(); }
@Override protected Query applyArrayReference(Reference arrayReference, Literal literal, Context context) throws IOException { String regexString = LikeOperator.patternToRegex(BytesRefs.toString(literal.value()), LikeOperator.DEFAULT_ESCAPE, false); regexString = regexString.substring(1, regexString.length() - 1); String notLike = negateWildcard(regexString); return new RegexpQuery(new Term( arrayReference.info().ident().columnIdent().fqn(), notLike), RegexpFlag.COMPLEMENT.value() ); }
/** * Sets the regular expression syntax flags * see {@link RegexpFlag} */ public Builder setFlags(String flags) { this.flagsValue = RegexpFlag.resolveValue(flags); return this; }