set) {
- switch (kind) {
- case REGEXP_UNION:
- case REGEXP_CONCATENATION:
- case REGEXP_INTERSECTION:
- exp1.getIdentifiers(set);
- exp2.getIdentifiers(set);
- break;
- case REGEXP_OPTIONAL:
- case REGEXP_REPEAT:
- case REGEXP_REPEAT_MIN:
- case REGEXP_REPEAT_MINMAX:
- case REGEXP_COMPLEMENT:
- exp1.getIdentifiers(set);
- break;
- case REGEXP_AUTOMATON:
- set.add(s);
- break;
- default:
- }
- }
-
- static RegExp87 makeUnion(int flags, RegExp87 exp1, RegExp87 exp2) {
- return newContainerNode(flags, Kind.REGEXP_UNION, exp1, exp2);
- }
-
- static RegExp87 makeConcatenation(int flags, RegExp87 exp1, RegExp87 exp2) {
- if ((exp1.kind == Kind.REGEXP_CHAR || exp1.kind == Kind.REGEXP_STRING)
- && (exp2.kind == Kind.REGEXP_CHAR || exp2.kind == Kind.REGEXP_STRING)) return makeString(
- flags, exp1, exp2);
- RegExp87 rexp1, rexp2;
- if (exp1.kind == Kind.REGEXP_CONCATENATION
- && (exp1.exp2.kind == Kind.REGEXP_CHAR || exp1.exp2.kind == Kind.REGEXP_STRING)
- && (exp2.kind == Kind.REGEXP_CHAR || exp2.kind == Kind.REGEXP_STRING)) {
- rexp1 = exp1.exp1;
- rexp2 = makeString(flags, exp1.exp2, exp2);
- } else if ((exp1.kind == Kind.REGEXP_CHAR || exp1.kind == Kind.REGEXP_STRING)
- && exp2.kind == Kind.REGEXP_CONCATENATION
- && (exp2.exp1.kind == Kind.REGEXP_CHAR || exp2.exp1.kind == Kind.REGEXP_STRING)) {
- rexp1 = makeString(flags, exp1, exp2.exp1);
- rexp2 = exp2.exp2;
- } else {
- rexp1 = exp1;
- rexp2 = exp2;
- }
- return newContainerNode(flags, Kind.REGEXP_CONCATENATION, rexp1, rexp2);
- }
-
- private static RegExp87 makeString(int flags, RegExp87 exp1, RegExp87 exp2) {
- StringBuilder b = new StringBuilder();
- if (exp1.kind == Kind.REGEXP_STRING) b.append(exp1.s);
- else b.appendCodePoint(exp1.c);
- if (exp2.kind == Kind.REGEXP_STRING) b.append(exp2.s);
- else b.appendCodePoint(exp2.c);
- return makeString(flags, b.toString());
- }
-
- static RegExp87 makeIntersection(int flags, RegExp87 exp1, RegExp87 exp2) {
- return newContainerNode(flags, Kind.REGEXP_INTERSECTION, exp1, exp2);
- }
-
- static RegExp87 makeOptional(int flags, RegExp87 exp) {
- return newContainerNode(flags, Kind.REGEXP_OPTIONAL, exp, null);
- }
-
- static RegExp87 makeRepeat(int flags, RegExp87 exp) {
- return newContainerNode(flags, Kind.REGEXP_REPEAT, exp, null);
- }
-
- static RegExp87 makeRepeat(int flags, RegExp87 exp, int min) {
- return newRepeatingNode(flags, Kind.REGEXP_REPEAT_MIN, exp, min, 0);
- }
-
- static RegExp87 makeRepeat(int flags, RegExp87 exp, int min, int max) {
- return newRepeatingNode(flags, Kind.REGEXP_REPEAT_MINMAX, exp, min, max);
- }
-
- static RegExp87 makeComplement(int flags, RegExp87 exp) {
- return newContainerNode(flags, Kind.REGEXP_COMPLEMENT, exp, null);
- }
-
- static RegExp87 makeChar(int flags, int c) {
- return newLeafNode(flags, Kind.REGEXP_CHAR, null, c, 0, 0, 0, 0, 0);
- }
-
- static RegExp87 makeCharRange(int flags, int from, int to) {
- if (from > to)
- throw new IllegalArgumentException("invalid range: from (" + from + ") cannot be > to (" + to + ")");
- return newLeafNode(flags, Kind.REGEXP_CHAR_RANGE, null, 0, 0, 0, 0, from, to);
- }
-
- static RegExp87 makeAnyChar(int flags) {
- return newContainerNode(flags, Kind.REGEXP_ANYCHAR, null, null);
- }
-
- static RegExp87 makeEmpty(int flags) {
- return newContainerNode(flags, Kind.REGEXP_EMPTY, null, null);
- }
-
- static RegExp87 makeString(int flags, String s) {
- return newLeafNode(flags, Kind.REGEXP_STRING, s, 0, 0, 0, 0, 0, 0);
- }
-
- static RegExp87 makeAnyString(int flags) {
- return newContainerNode(flags, Kind.REGEXP_ANYSTRING, null, null);
- }
-
- static RegExp87 makeAutomaton(int flags, String s) {
- return newLeafNode(flags, Kind.REGEXP_AUTOMATON, s, 0, 0, 0, 0, 0, 0);
- }
-
- static RegExp87 makeInterval(int flags, int min, int max, int digits) {
- return newLeafNode(flags, Kind.REGEXP_INTERVAL, null, 0, min, max, digits, 0, 0);
- }
-
- private boolean peek(String s) {
- return more() && s.indexOf(originalString.codePointAt(pos)) != -1;
- }
-
- private boolean match(int c) {
- if (pos >= originalString.length()) return false;
- if (originalString.codePointAt(pos) == c) {
- pos += Character.charCount(c);
- return true;
- }
- return false;
- }
-
- private boolean more() {
- return pos < originalString.length();
- }
-
- private int next() throws IllegalArgumentException {
- if (!more()) throw new IllegalArgumentException("unexpected end-of-string");
- int ch = originalString.codePointAt(pos);
- pos += Character.charCount(ch);
- return ch;
- }
-
- private boolean check(int flag) {
- return (flags & flag) != 0;
- }
-
- final RegExp87 parseUnionExp() throws IllegalArgumentException {
- RegExp87 e = parseInterExp();
- if (match('|')) e = makeUnion(flags, e, parseUnionExp());
- return e;
- }
-
- final RegExp87 parseInterExp() throws IllegalArgumentException {
- RegExp87 e = parseConcatExp();
- if (check(INTERSECTION) && match('&')) e = makeIntersection(flags, e,
- parseInterExp());
- return e;
- }
-
- final RegExp87 parseConcatExp() throws IllegalArgumentException {
- RegExp87 e = parseRepeatExp();
- if (more() && !peek(")|") && (!check(INTERSECTION) || !peek("&"))) e = makeConcatenation(
- flags, e, parseConcatExp());
- return e;
- }
-
- final RegExp87 parseRepeatExp() throws IllegalArgumentException {
- RegExp87 e = parseComplExp();
- while (peek("?*+{")) {
- if (match('?')) e = makeOptional(flags, e);
- else if (match('*')) e = makeRepeat(flags, e);
- else if (match('+')) e = makeRepeat(flags, e, 1);
- else if (match('{')) {
- int start = pos;
- while (peek("0123456789"))
- next();
- if (start == pos) throw new IllegalArgumentException(
- "integer expected at position " + pos);
- int n = Integer.parseInt(originalString.substring(start, pos));
- int m = -1;
- if (match(',')) {
- start = pos;
- while (peek("0123456789"))
- next();
- if (start != pos) m = Integer.parseInt(
- originalString.substring(start, pos));
- } else m = n;
- if (!match('}')) throw new IllegalArgumentException(
- "expected '}' at position " + pos);
- if (m == -1) e = makeRepeat(flags, e, n);
- else e = makeRepeat(flags, e, n, m);
- }
- }
- return e;
- }
-
- final RegExp87 parseComplExp() throws IllegalArgumentException {
- if (check(COMPLEMENT) && match('~')) return makeComplement(flags, parseComplExp());
- else return parseCharClassExp();
- }
-
- final RegExp87 parseCharClassExp() throws IllegalArgumentException {
- if (match('[')) {
- boolean negate = false;
- if (match('^')) negate = true;
- RegExp87 e = parseCharClasses();
- if (negate) e = makeIntersection(flags, makeAnyChar(flags), makeComplement(flags, e));
- if (!match(']')) throw new IllegalArgumentException(
- "expected ']' at position " + pos);
- return e;
- } else return parseSimpleExp();
- }
-
- final RegExp87 parseCharClasses() throws IllegalArgumentException {
- RegExp87 e = parseCharClass();
- while (more() && !peek("]"))
- e = makeUnion(flags, e, parseCharClass());
- return e;
- }
-
- final RegExp87 parseCharClass() throws IllegalArgumentException {
- RegExp87 predefinedExp = matchPredefinedCharacterClass();
- if (predefinedExp != null) {
- return predefinedExp;
- }
-
- int c = parseCharExp();
- if (match('-')) return makeCharRange(flags, c, parseCharExp());
- else return makeChar(flags, c);
- }
-
- RegExp87 expandPredefined() {
- //See https://docs.oracle.com/javase/tutorial/essential/regex/pre_char_classes.html
- switch (from) {
- case 'd':
- return new RegExp87("[0-9]"); // digit
- case 'D':
- return new RegExp87("[^0-9]"); // non-digit
- case 's':
- return new RegExp87("[ \t\n\r]"); // whitespace
- case 'S':
- return new RegExp87("[^\\s]"); // non-whitespace
- case 'w':
- return new RegExp87("[a-zA-Z_0-9]"); // word
- case 'W':
- return new RegExp87("[^\\w]"); // non-word
- default:
- throw new IllegalArgumentException(
- "invalid character class " + from);
- }
- }
-
-
- final RegExp87 matchPredefinedCharacterClass() {
- //See https://docs.oracle.com/javase/tutorial/essential/regex/pre_char_classes.html
- if (match('\\')) {
- if (peek("dDwWsS")) {
- return newLeafNode(flags, Kind.REGEXP_PRE_CLASS, null, 0, 0, 0, 0, next(), 0);
- }
-
- if (peek("\\")) {
- return makeChar(flags, next());
- }
-
- // From https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html#bs
- // "It is an error to use a backslash prior to any alphabetic character that does not denote an escaped
- // construct;"
- if (peek("abcefghijklmnopqrtuvxyz") || peek("ABCEFGHIJKLMNOPQRTUVXYZ")) {
- throw new IllegalArgumentException("invalid character class \\" + next());
- }
- }
-
- return null;
- }
-
-
- final RegExp87 parseSimpleExp() throws IllegalArgumentException {
- if (match('.')) return makeAnyChar(flags);
- else if (check(EMPTY) && match('#')) return makeEmpty(flags);
- else if (check(ANYSTRING) && match('@')) return makeAnyString(flags);
- else if (match('"')) {
- int start = pos;
- while (more() && !peek("\""))
- next();
- if (!match('"')) throw new IllegalArgumentException(
- "expected '\"' at position " + pos);
- return makeString(flags, originalString.substring(start, pos - 1));
- } else if (match('(')) {
- if (match(')')) return makeString(flags, "");
- RegExp87 e = parseUnionExp();
- if (!match(')')) throw new IllegalArgumentException(
- "expected ')' at position " + pos);
- return e;
- } else if ((check(AUTOMATON) || check(INTERVAL)) && match('<')) {
- int start = pos;
- while (more() && !peek(">"))
- next();
- if (!match('>')) throw new IllegalArgumentException(
- "expected '>' at position " + pos);
- String s = originalString.substring(start, pos - 1);
- int i = s.indexOf('-');
- if (i == -1) {
- if (!check(AUTOMATON)) throw new IllegalArgumentException(
- "interval syntax error at position " + (pos - 1));
- return makeAutomaton(flags, s);
- } else {
- if (!check(INTERVAL)) throw new IllegalArgumentException(
- "illegal identifier at position " + (pos - 1));
- try {
- if (i == 0 || i == s.length() - 1 || i != s.lastIndexOf('-')) throw new NumberFormatException();
- String smin = s.substring(0, i);
- String smax = s.substring(i + 1, s.length());
- int imin = Integer.parseInt(smin);
- int imax = Integer.parseInt(smax);
- int digits;
- if (smin.length() == smax.length()) digits = smin.length();
- else digits = 0;
- if (imin > imax) {
- int t = imin;
- imin = imax;
- imax = t;
- }
- return makeInterval(flags, imin, imax, digits);
- } catch (NumberFormatException e) {
- throw new IllegalArgumentException(
- "interval syntax error at position " + (pos - 1));
- }
- }
- } else {
- RegExp87 predefined = matchPredefinedCharacterClass();
- if (predefined != null) {
- return predefined;
- }
- return makeChar(flags, parseCharExp());
- }
- }
-
- final int parseCharExp() throws IllegalArgumentException {
- match('\\');
- return next();
- }
-}
diff --git a/server/src/main/java/org/apache/lucene/search/RegexpQuery87.java b/server/src/main/java/org/apache/lucene/search/RegexpQuery87.java
deleted file mode 100644
index 8bf07e3ad6d98..0000000000000
--- a/server/src/main/java/org/apache/lucene/search/RegexpQuery87.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.lucene.search;
-
-
-import org.apache.lucene.index.Term;
-import org.apache.lucene.util.automaton.Automaton;
-import org.apache.lucene.util.automaton.AutomatonProvider;
-import org.apache.lucene.util.automaton.Operations;
-
-/**
- * Copy of Lucene's RegExpQuery class coming in 8.7 with case
- * insensitive search option
- * @deprecated
- */
-@Deprecated
-public class RegexpQuery87 extends AutomatonQuery {
- /**
- * A provider that provides no named automata
- */
- private static AutomatonProvider defaultProvider = new AutomatonProvider() {
- @Override
- public Automaton getAutomaton(String name) {
- return null;
- }
- };
-
- /**
- * Constructs a query for terms matching term
.
- *
- * By default, all regular expression features are enabled.
- *
- *
- * @param term regular expression.
- */
- public RegexpQuery87(Term term) {
- this(term, RegExp87.ALL);
- }
-
- /**
- * Constructs a query for terms matching term
.
- *
- * @param term regular expression.
- * @param flags optional RegExp features from {@link RegExp87}
- */
- public RegexpQuery87(Term term, int flags) {
- this(term, flags, defaultProvider,
- Operations.DEFAULT_MAX_DETERMINIZED_STATES);
- }
-
- /**
- * Constructs a query for terms matching term
.
- *
- * @param term regular expression.
- * @param flags optional RegExp syntax features from {@link RegExp87}
- * @param maxDeterminizedStates maximum number of states that compiling the
- * automaton for the regexp can result in. Set higher to allow more complex
- * queries and lower to prevent memory exhaustion.
- */
- public RegexpQuery87(Term term, int flags, int maxDeterminizedStates) {
- this(term, flags, defaultProvider, maxDeterminizedStates);
- }
-
- /**
- * Constructs a query for terms matching term
.
- *
- * @param term regular expression.
- * @param syntax_flags optional RegExp syntax features from {@link RegExp87}
- * automaton for the regexp can result in. Set higher to allow more complex
- * queries and lower to prevent memory exhaustion.
- * @param match_flags boolean 'or' of match behavior options such as case insensitivity
- * @param maxDeterminizedStates maximum number of states that compiling the
- */
- public RegexpQuery87(Term term, int syntax_flags, int match_flags, int maxDeterminizedStates) {
- this(term, syntax_flags, match_flags, defaultProvider, maxDeterminizedStates);
- }
-
- /**
- * Constructs a query for terms matching term
.
- *
- * @param term regular expression.
- * @param syntax_flags optional RegExp features from {@link RegExp87}
- * @param provider custom AutomatonProvider for named automata
- * @param maxDeterminizedStates maximum number of states that compiling the
- * automaton for the regexp can result in. Set higher to allow more complex
- * queries and lower to prevent memory exhaustion.
- */
- public RegexpQuery87(Term term, int syntax_flags, AutomatonProvider provider,
- int maxDeterminizedStates) {
- this(term, syntax_flags, 0, provider, maxDeterminizedStates);
- }
-
- /**
- * Constructs a query for terms matching term
.
- *
- * @param term regular expression.
- * @param syntax_flags optional RegExp features from {@link RegExp87}
- * @param match_flags boolean 'or' of match behavior options such as case insensitivity
- * @param provider custom AutomatonProvider for named automata
- * @param maxDeterminizedStates maximum number of states that compiling the
- * automaton for the regexp can result in. Set higher to allow more complex
- * queries and lower to prevent memory exhaustion.
- */
- public RegexpQuery87(Term term, int syntax_flags, int match_flags, AutomatonProvider provider,
- int maxDeterminizedStates) {
- super(term,
- new RegExp87(term.text(), syntax_flags, match_flags).toAutomaton(
- provider, maxDeterminizedStates), maxDeterminizedStates);
- }
-
- /** Returns the regexp of this query wrapped in a Term. */
- public Term getRegexp() {
- return term;
- }
-
- /** Prints a user-readable version of this query. */
- @Override
- public String toString(String field) {
- StringBuilder buffer = new StringBuilder();
- if (!term.field().equals(field)) {
- buffer.append(term.field());
- buffer.append(":");
- }
- buffer.append('/');
- buffer.append(term.text());
- buffer.append('/');
- return buffer.toString();
- }
-}
diff --git a/server/src/main/java/org/elasticsearch/Version.java b/server/src/main/java/org/elasticsearch/Version.java
index a4db867de7fa9..c7218c97b0764 100644
--- a/server/src/main/java/org/elasticsearch/Version.java
+++ b/server/src/main/java/org/elasticsearch/Version.java
@@ -83,7 +83,7 @@ public class Version implements Comparable, ToXContentFragment {
public static final Version V_7_9_1 = new Version(7090199, org.apache.lucene.util.Version.LUCENE_8_6_2);
public static final Version V_7_9_2 = new Version(7090299, org.apache.lucene.util.Version.LUCENE_8_6_2);
public static final Version V_7_10_0 = new Version(7100099, org.apache.lucene.util.Version.LUCENE_8_6_2);
- public static final Version V_8_0_0 = new Version(8000099, org.apache.lucene.util.Version.LUCENE_8_6_2);
+ public static final Version V_8_0_0 = new Version(8000099, org.apache.lucene.util.Version.LUCENE_8_7_0);
public static final Version CURRENT = V_8_0_0;
private static final ImmutableOpenIntMap idToVersion;
diff --git a/server/src/main/java/org/elasticsearch/common/lucene/Lucene.java b/server/src/main/java/org/elasticsearch/common/lucene/Lucene.java
index 18b4d303f0adb..7bbc80bee6d19 100644
--- a/server/src/main/java/org/elasticsearch/common/lucene/Lucene.java
+++ b/server/src/main/java/org/elasticsearch/common/lucene/Lucene.java
@@ -104,7 +104,7 @@
import java.util.Map;
public class Lucene {
- public static final String LATEST_CODEC = "Lucene86";
+ public static final String LATEST_CODEC = "Lucene87";
public static final String SOFT_DELETES_FIELD = "__soft_deletes";
diff --git a/server/src/main/java/org/elasticsearch/index/codec/CodecService.java b/server/src/main/java/org/elasticsearch/index/codec/CodecService.java
index a8ca5ba478667..d88d97335704c 100644
--- a/server/src/main/java/org/elasticsearch/index/codec/CodecService.java
+++ b/server/src/main/java/org/elasticsearch/index/codec/CodecService.java
@@ -21,8 +21,8 @@
import org.apache.logging.log4j.Logger;
import org.apache.lucene.codecs.Codec;
-import org.apache.lucene.codecs.lucene50.Lucene50StoredFieldsFormat.Mode;
-import org.apache.lucene.codecs.lucene86.Lucene86Codec;
+import org.apache.lucene.codecs.lucene87.Lucene87Codec;
+import org.apache.lucene.codecs.lucene87.Lucene87StoredFieldsFormat.Mode;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.index.mapper.MapperService;
@@ -47,8 +47,8 @@ public class CodecService {
public CodecService(@Nullable MapperService mapperService, Logger logger) {
final var codecs = new HashMap();
if (mapperService == null) {
- codecs.put(DEFAULT_CODEC, new Lucene86Codec());
- codecs.put(BEST_COMPRESSION_CODEC, new Lucene86Codec(Mode.BEST_COMPRESSION));
+ codecs.put(DEFAULT_CODEC, new Lucene87Codec());
+ codecs.put(BEST_COMPRESSION_CODEC, new Lucene87Codec(Mode.BEST_COMPRESSION));
} else {
codecs.put(DEFAULT_CODEC,
new PerFieldMappingPostingFormatCodec(Mode.BEST_SPEED, mapperService, logger));
diff --git a/server/src/main/java/org/elasticsearch/index/codec/PerFieldMappingPostingFormatCodec.java b/server/src/main/java/org/elasticsearch/index/codec/PerFieldMappingPostingFormatCodec.java
index e900351fcbebd..fda96bbd9335f 100644
--- a/server/src/main/java/org/elasticsearch/index/codec/PerFieldMappingPostingFormatCodec.java
+++ b/server/src/main/java/org/elasticsearch/index/codec/PerFieldMappingPostingFormatCodec.java
@@ -22,8 +22,8 @@
import org.apache.logging.log4j.Logger;
import org.apache.lucene.codecs.Codec;
import org.apache.lucene.codecs.PostingsFormat;
-import org.apache.lucene.codecs.lucene50.Lucene50StoredFieldsFormat;
-import org.apache.lucene.codecs.lucene86.Lucene86Codec;
+import org.apache.lucene.codecs.lucene87.Lucene87StoredFieldsFormat;
+import org.apache.lucene.codecs.lucene87.Lucene87Codec;
import org.elasticsearch.common.lucene.Lucene;
import org.elasticsearch.index.mapper.CompletionFieldMapper;
import org.elasticsearch.index.mapper.MappedFieldType;
@@ -37,7 +37,7 @@
* per index in real time via the mapping API. If no specific postings format is
* configured for a specific field the default postings format is used.
*/
-public class PerFieldMappingPostingFormatCodec extends Lucene86Codec {
+public class PerFieldMappingPostingFormatCodec extends Lucene87Codec {
private final Logger logger;
private final MapperService mapperService;
@@ -46,7 +46,7 @@ public class PerFieldMappingPostingFormatCodec extends Lucene86Codec {
"PerFieldMappingPostingFormatCodec must subclass the latest " + "lucene codec: " + Lucene.LATEST_CODEC;
}
- public PerFieldMappingPostingFormatCodec(Lucene50StoredFieldsFormat.Mode compressionMode, MapperService mapperService, Logger logger) {
+ public PerFieldMappingPostingFormatCodec(Lucene87StoredFieldsFormat.Mode compressionMode, MapperService mapperService, Logger logger) {
super(compressionMode);
this.mapperService = mapperService;
this.logger = logger;
diff --git a/server/src/main/java/org/elasticsearch/index/mapper/StringFieldType.java b/server/src/main/java/org/elasticsearch/index/mapper/StringFieldType.java
index b38ebfdd32ae0..daa5f470c1def 100644
--- a/server/src/main/java/org/elasticsearch/index/mapper/StringFieldType.java
+++ b/server/src/main/java/org/elasticsearch/index/mapper/StringFieldType.java
@@ -25,7 +25,7 @@
import org.apache.lucene.search.MultiTermQuery;
import org.apache.lucene.search.PrefixQuery;
import org.apache.lucene.search.Query;
-import org.apache.lucene.search.RegexpQuery87;
+import org.apache.lucene.search.RegexpQuery;
import org.apache.lucene.search.TermRangeQuery;
import org.apache.lucene.search.WildcardQuery;
import org.apache.lucene.util.BytesRef;
@@ -141,7 +141,7 @@ public Query regexpQuery(String value, int syntaxFlags, int matchFlags, int maxD
ALLOW_EXPENSIVE_QUERIES.getKey() + "' is set to false.");
}
failIfNotIndexed();
- RegexpQuery87 query = new RegexpQuery87(new Term(name(), indexedValueForSearch(value)), syntaxFlags,
+ RegexpQuery query = new RegexpQuery(new Term(name(), indexedValueForSearch(value)), syntaxFlags,
matchFlags, maxDeterminizedStates);
if (method != null) {
query.setRewriteMethod(method);
diff --git a/server/src/main/java/org/elasticsearch/index/query/RegexpFlag.java b/server/src/main/java/org/elasticsearch/index/query/RegexpFlag.java
index 37388cd5cf254..669c885276f46 100644
--- a/server/src/main/java/org/elasticsearch/index/query/RegexpFlag.java
+++ b/server/src/main/java/org/elasticsearch/index/query/RegexpFlag.java
@@ -18,7 +18,7 @@
*/
package org.elasticsearch.index.query;
-import org.apache.lucene.search.RegExp87;
+import org.apache.lucene.util.automaton.RegExp;
import org.elasticsearch.common.Strings;
import java.util.Locale;
@@ -43,37 +43,37 @@ public enum RegexpFlag {
/**
* Enables intersection of the form: {@code <expression> & <expression>}
*/
- INTERSECTION(RegExp87.INTERSECTION),
+ INTERSECTION(RegExp.INTERSECTION),
/**
* Enables complement expression of the form: {@code ~<expression>}
*/
- COMPLEMENT(RegExp87.COMPLEMENT),
+ COMPLEMENT(RegExp.COMPLEMENT),
/**
* Enables empty language expression: {@code #}
*/
- EMPTY(RegExp87.EMPTY),
+ EMPTY(RegExp.EMPTY),
/**
* Enables any string expression: {@code @}
*/
- ANYSTRING(RegExp87.ANYSTRING),
+ ANYSTRING(RegExp.ANYSTRING),
/**
* Enables numerical interval expression: {@code <n-m>}
*/
- INTERVAL(RegExp87.INTERVAL),
+ INTERVAL(RegExp.INTERVAL),
/**
* Disables all available option flags
*/
- NONE(RegExp87.NONE),
+ NONE(RegExp.NONE),
/**
* Enables all available option flags
*/
- ALL(RegExp87.ALL);
+ ALL(RegExp.ALL);
final int value;
@@ -110,9 +110,9 @@ public int value() {
*/
public static int resolveValue(String flags) {
if (flags == null || flags.isEmpty()) {
- return RegExp87.ALL;
+ return RegExp.ALL;
}
- int magic = RegExp87.NONE;
+ int magic = RegExp.NONE;
for (String s : Strings.delimitedListToStringArray(flags, "|")) {
if (s.isEmpty()) {
continue;
diff --git a/server/src/main/java/org/elasticsearch/index/query/RegexpQueryBuilder.java b/server/src/main/java/org/elasticsearch/index/query/RegexpQueryBuilder.java
index 0a99cc7e7ac6a..3cf1935801e1b 100644
--- a/server/src/main/java/org/elasticsearch/index/query/RegexpQueryBuilder.java
+++ b/server/src/main/java/org/elasticsearch/index/query/RegexpQueryBuilder.java
@@ -22,9 +22,9 @@
import org.apache.lucene.index.Term;
import org.apache.lucene.search.MultiTermQuery;
import org.apache.lucene.search.Query;
-import org.apache.lucene.search.RegExp87;
-import org.apache.lucene.search.RegexpQuery87;
+import org.apache.lucene.search.RegexpQuery;
import org.apache.lucene.util.automaton.Operations;
+import org.apache.lucene.util.automaton.RegExp;
import org.elasticsearch.Version;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.ParsingException;
@@ -152,19 +152,19 @@ public RegexpQueryBuilder flags(int flags) {
public int flags() {
return this.syntaxFlagsValue;
}
-
+
public RegexpQueryBuilder caseInsensitive(boolean caseInsensitive) {
if (caseInsensitive == false) {
throw new IllegalArgumentException("The case insensitive setting cannot be set to false.");
}
this.caseInsensitive = caseInsensitive;
return this;
- }
+ }
public boolean caseInsensitive() {
return this.caseInsensitive;
}
-
+
/**
* Sets the regexp maxDeterminizedStates.
*/
@@ -288,17 +288,17 @@ protected Query doToQuery(QueryShardContext context) throws QueryShardException,
}
MultiTermQuery.RewriteMethod method = QueryParsers.parseRewriteMethod(rewrite, null, LoggingDeprecationHandler.INSTANCE);
- int matchFlagsValue = caseInsensitive ? RegExp87.ASCII_CASE_INSENSITIVE : 0;
+ int matchFlagsValue = caseInsensitive ? RegExp.ASCII_CASE_INSENSITIVE : 0;
Query query = null;
// For BWC we mask irrelevant bits (RegExp changed ALL from 0xffff to 0xff)
- int sanitisedSyntaxFlag = syntaxFlagsValue & RegExp87.ALL;
+ int sanitisedSyntaxFlag = syntaxFlagsValue & RegExp.ALL;
MappedFieldType fieldType = context.fieldMapper(fieldName);
if (fieldType != null) {
query = fieldType.regexpQuery(value, sanitisedSyntaxFlag, matchFlagsValue, maxDeterminizedStates, method, context);
}
if (query == null) {
- RegexpQuery87 regexpQuery = new RegexpQuery87(new Term(fieldName, BytesRefs.toBytesRef(value)), sanitisedSyntaxFlag,
+ RegexpQuery regexpQuery = new RegexpQuery(new Term(fieldName, BytesRefs.toBytesRef(value)), sanitisedSyntaxFlag,
matchFlagsValue, maxDeterminizedStates);
if (method != null) {
regexpQuery.setRewriteMethod(method);
diff --git a/server/src/main/java/org/elasticsearch/index/search/QueryStringQueryParser.java b/server/src/main/java/org/elasticsearch/index/search/QueryStringQueryParser.java
index abeedeef202ee..b18a82ce54958 100644
--- a/server/src/main/java/org/elasticsearch/index/search/QueryStringQueryParser.java
+++ b/server/src/main/java/org/elasticsearch/index/search/QueryStringQueryParser.java
@@ -37,13 +37,13 @@
import org.apache.lucene.search.MultiTermQuery;
import org.apache.lucene.search.PhraseQuery;
import org.apache.lucene.search.Query;
-import org.apache.lucene.search.RegExp87;
import org.apache.lucene.search.SynonymQuery;
import org.apache.lucene.search.WildcardQuery;
import org.apache.lucene.search.spans.SpanNearQuery;
import org.apache.lucene.search.spans.SpanOrQuery;
import org.apache.lucene.search.spans.SpanQuery;
import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.automaton.RegExp;
import org.elasticsearch.common.lucene.search.Queries;
import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.common.unit.Fuzziness;
@@ -675,13 +675,13 @@ private Query getWildcardQuerySingle(String field, String termStr) throws ParseE
MappedFieldType currentFieldType = queryBuilder.context.fieldMapper(field);
if (currentFieldType == null) {
return newUnmappedFieldQuery(field);
- }
- if (forceAnalyzer != null &&
+ }
+ if (forceAnalyzer != null &&
(analyzeWildcard || currentFieldType.getTextSearchInfo().isTokenized())) {
setAnalyzer(forceAnalyzer);
return super.getWildcardQuery(currentFieldType.name(), termStr);
}
-
+
return currentFieldType.wildcardQuery(termStr, getMultiTermRewriteMethod(), context);
} catch (RuntimeException e) {
if (lenient) {
@@ -730,8 +730,8 @@ private Query getRegexpQuerySingle(String field, String termStr) throws ParseExc
if (forceAnalyzer != null) {
setAnalyzer(forceAnalyzer);
return super.getRegexpQuery(field, termStr);
- }
- return currentFieldType.regexpQuery(termStr, RegExp87.ALL, 0, getMaxDeterminizedStates(),
+ }
+ return currentFieldType.regexpQuery(termStr, RegExp.ALL, 0, getMaxDeterminizedStates(),
getMultiTermRewriteMethod(), context);
} catch (RuntimeException e) {
if (lenient) {
diff --git a/server/src/main/java/org/elasticsearch/search/suggest/completion/RegexOptions.java b/server/src/main/java/org/elasticsearch/search/suggest/completion/RegexOptions.java
index d7d84bb4ceb93..da42ea6e0cbb2 100644
--- a/server/src/main/java/org/elasticsearch/search/suggest/completion/RegexOptions.java
+++ b/server/src/main/java/org/elasticsearch/search/suggest/completion/RegexOptions.java
@@ -19,15 +19,14 @@
package org.elasticsearch.search.suggest.completion;
-import org.apache.lucene.search.RegExp87;
import org.apache.lucene.util.automaton.Operations;
+import org.apache.lucene.util.automaton.RegExp;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.common.xcontent.ObjectParser;
-import org.elasticsearch.common.xcontent.ToXContent.Params;
import org.elasticsearch.common.xcontent.ToXContentFragment;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
@@ -143,7 +142,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
* Options for regular expression queries
*/
public static class Builder {
- private int flagsValue = RegExp87.ALL;
+ private int flagsValue = RegExp.ALL;
private int maxDeterminizedStates = Operations.DEFAULT_MAX_DETERMINIZED_STATES;
public Builder() {
diff --git a/server/src/test/java/org/elasticsearch/index/codec/CodecTests.java b/server/src/test/java/org/elasticsearch/index/codec/CodecTests.java
index 47cfea54c65a0..aa86888cdefe9 100644
--- a/server/src/test/java/org/elasticsearch/index/codec/CodecTests.java
+++ b/server/src/test/java/org/elasticsearch/index/codec/CodecTests.java
@@ -21,9 +21,9 @@
import org.apache.logging.log4j.LogManager;
import org.apache.lucene.codecs.Codec;
-import org.apache.lucene.codecs.lucene50.Lucene50StoredFieldsFormat;
-import org.apache.lucene.codecs.lucene50.Lucene50StoredFieldsFormat.Mode;
-import org.apache.lucene.codecs.lucene86.Lucene86Codec;
+import org.apache.lucene.codecs.lucene87.Lucene87Codec;
+import org.apache.lucene.codecs.lucene87.Lucene87StoredFieldsFormat;
+import org.apache.lucene.codecs.lucene87.Lucene87StoredFieldsFormat.Mode;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexWriter;
@@ -53,8 +53,8 @@ public class CodecTests extends ESTestCase {
public void testResolveDefaultCodecs() throws Exception {
CodecService codecService = createCodecService();
assertThat(codecService.codec("default"), instanceOf(PerFieldMappingPostingFormatCodec.class));
- assertThat(codecService.codec("default"), instanceOf(Lucene86Codec.class));
- assertThat(codecService.codec("Lucene86"), instanceOf(Lucene86Codec.class));
+ assertThat(codecService.codec("default"), instanceOf(Lucene87Codec.class));
+ assertThat(codecService.codec("Lucene87"), instanceOf(Lucene87Codec.class));
}
public void testDefault() throws Exception {
@@ -78,7 +78,7 @@ private void assertCompressionEquals(Mode expected, Codec actual) throws Excepti
iw.close();
DirectoryReader ir = DirectoryReader.open(dir);
SegmentReader sr = (SegmentReader) ir.leaves().get(0).reader();
- String v = sr.getSegmentInfo().info.getAttribute(Lucene50StoredFieldsFormat.MODE_KEY);
+ String v = sr.getSegmentInfo().info.getAttribute(Lucene87StoredFieldsFormat.MODE_KEY);
assertNotNull(v);
assertEquals(expected, Mode.valueOf(v));
ir.close();
diff --git a/server/src/test/java/org/elasticsearch/index/engine/CompletionStatsCacheTests.java b/server/src/test/java/org/elasticsearch/index/engine/CompletionStatsCacheTests.java
index 856c1d8653c84..f53786c4fc1da 100644
--- a/server/src/test/java/org/elasticsearch/index/engine/CompletionStatsCacheTests.java
+++ b/server/src/test/java/org/elasticsearch/index/engine/CompletionStatsCacheTests.java
@@ -19,7 +19,7 @@
package org.elasticsearch.index.engine;
import org.apache.lucene.codecs.PostingsFormat;
-import org.apache.lucene.codecs.lucene86.Lucene86Codec;
+import org.apache.lucene.codecs.lucene87.Lucene87Codec;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexWriter;
@@ -57,7 +57,7 @@ public void testExceptionsAreNotCached() {
public void testCompletionStatsCache() throws IOException, InterruptedException {
final IndexWriterConfig indexWriterConfig = newIndexWriterConfig();
final PostingsFormat postingsFormat = new Completion84PostingsFormat();
- indexWriterConfig.setCodec(new Lucene86Codec() {
+ indexWriterConfig.setCodec(new Lucene87Codec() {
@Override
public PostingsFormat getPostingsFormatForField(String field) {
return postingsFormat; // all fields are suggest fields
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/CompletionFieldMapperTests.java b/server/src/test/java/org/elasticsearch/index/mapper/CompletionFieldMapperTests.java
index 21ea28fd921b3..6ec48c2ea30b7 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/CompletionFieldMapperTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/CompletionFieldMapperTests.java
@@ -22,7 +22,6 @@
import org.apache.lucene.document.SortedSetDocValuesField;
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.search.Query;
-import org.apache.lucene.search.RegExp87;
import org.apache.lucene.search.suggest.document.CompletionAnalyzer;
import org.apache.lucene.search.suggest.document.ContextSuggestField;
import org.apache.lucene.search.suggest.document.FuzzyCompletionQuery;
@@ -32,6 +31,7 @@
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.CharsRefBuilder;
import org.apache.lucene.util.automaton.Operations;
+import org.apache.lucene.util.automaton.RegExp;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.Strings;
@@ -886,7 +886,7 @@ public void testRegexQueryType() throws Exception {
Mapper fieldMapper = defaultMapper.mappers().getMapper("completion");
CompletionFieldMapper completionFieldMapper = (CompletionFieldMapper) fieldMapper;
Query prefixQuery = completionFieldMapper.fieldType()
- .regexpQuery(new BytesRef("co"), RegExp87.ALL, Operations.DEFAULT_MAX_DETERMINIZED_STATES);
+ .regexpQuery(new BytesRef("co"), RegExp.ALL, Operations.DEFAULT_MAX_DETERMINIZED_STATES);
assertThat(prefixQuery, instanceOf(RegexCompletionQuery.class));
}
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/IgnoredFieldTypeTests.java b/server/src/test/java/org/elasticsearch/index/mapper/IgnoredFieldTypeTests.java
index c864a9c7742ce..cb9a75e523a6b 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/IgnoredFieldTypeTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/IgnoredFieldTypeTests.java
@@ -22,7 +22,7 @@
import org.apache.lucene.index.Term;
import org.apache.lucene.search.PrefixQuery;
import org.apache.lucene.search.Query;
-import org.apache.lucene.search.RegexpQuery87;
+import org.apache.lucene.search.RegexpQuery;
import org.apache.lucene.search.WildcardQuery;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.ElasticsearchException;
@@ -44,7 +44,7 @@ public void testPrefixQuery() {
public void testRegexpQuery() {
MappedFieldType ft = IgnoredFieldMapper.IgnoredFieldType.INSTANCE;
- Query expected = new RegexpQuery87(new Term("_ignored", new BytesRef("foo?")));
+ Query expected = new RegexpQuery(new Term("_ignored", new BytesRef("foo?")));
assertEquals(expected, ft.regexpQuery("foo?", 0, 0, 10, null, MOCK_QSC));
ElasticsearchException ee = expectThrows(ElasticsearchException.class,
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/KeywordFieldTypeTests.java b/server/src/test/java/org/elasticsearch/index/mapper/KeywordFieldTypeTests.java
index 85718f9fc8682..2e5210963869d 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/KeywordFieldTypeTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/KeywordFieldTypeTests.java
@@ -29,7 +29,7 @@
import org.apache.lucene.search.DocValuesFieldExistsQuery;
import org.apache.lucene.search.FuzzyQuery;
import org.apache.lucene.search.NormsFieldExistsQuery;
-import org.apache.lucene.search.RegexpQuery87;
+import org.apache.lucene.search.RegexpQuery;
import org.apache.lucene.search.TermInSetQuery;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TermRangeQuery;
@@ -128,7 +128,7 @@ public void testRangeQuery() {
public void testRegexpQuery() {
MappedFieldType ft = new KeywordFieldType("field");
- assertEquals(new RegexpQuery87(new Term("field","foo.*")),
+ assertEquals(new RegexpQuery(new Term("field","foo.*")),
ft.regexpQuery("foo.*", 0, 0, 10, null, MOCK_QSC));
MappedFieldType unsearchable = new KeywordFieldType("field", false, true, Collections.emptyMap());
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/RoutingFieldTypeTests.java b/server/src/test/java/org/elasticsearch/index/mapper/RoutingFieldTypeTests.java
index d4af02d356767..6055aad825bce 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/RoutingFieldTypeTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/RoutingFieldTypeTests.java
@@ -21,7 +21,7 @@
import org.apache.lucene.index.Term;
import org.apache.lucene.search.PrefixQuery;
import org.apache.lucene.search.Query;
-import org.apache.lucene.search.RegexpQuery87;
+import org.apache.lucene.search.RegexpQuery;
import org.apache.lucene.search.WildcardQuery;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.ElasticsearchException;
@@ -43,7 +43,7 @@ public void testPrefixQuery() {
public void testRegexpQuery() {
MappedFieldType ft = RoutingFieldMapper.RoutingFieldType.INSTANCE;
- Query expected = new RegexpQuery87(new Term("_routing", new BytesRef("foo?")));
+ Query expected = new RegexpQuery(new Term("_routing", new BytesRef("foo?")));
assertEquals(expected, ft.regexpQuery("foo?", 0, 0, 10, null, MOCK_QSC));
ElasticsearchException ee = expectThrows(ElasticsearchException.class,
diff --git a/server/src/test/java/org/elasticsearch/index/mapper/TextFieldTypeTests.java b/server/src/test/java/org/elasticsearch/index/mapper/TextFieldTypeTests.java
index 844d6c0cc22ec..73929a2eab896 100644
--- a/server/src/test/java/org/elasticsearch/index/mapper/TextFieldTypeTests.java
+++ b/server/src/test/java/org/elasticsearch/index/mapper/TextFieldTypeTests.java
@@ -26,7 +26,7 @@
import org.apache.lucene.search.FuzzyQuery;
import org.apache.lucene.search.PrefixQuery;
import org.apache.lucene.search.Query;
-import org.apache.lucene.search.RegexpQuery87;
+import org.apache.lucene.search.RegexpQuery;
import org.apache.lucene.search.TermInSetQuery;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TermRangeQuery;
@@ -86,7 +86,7 @@ public void testRangeQuery() {
public void testRegexpQuery() {
MappedFieldType ft = new TextFieldType("field");
- assertEquals(new RegexpQuery87(new Term("field","foo.*")),
+ assertEquals(new RegexpQuery(new Term("field","foo.*")),
ft.regexpQuery("foo.*", 0, 0, 10, null, MOCK_QSC));
MappedFieldType unsearchable = new TextFieldType("field", false, Collections.emptyMap());
diff --git a/server/src/test/java/org/elasticsearch/index/query/QueryStringQueryBuilderTests.java b/server/src/test/java/org/elasticsearch/index/query/QueryStringQueryBuilderTests.java
index be7b30ae17b54..feff2e0a713d5 100644
--- a/server/src/test/java/org/elasticsearch/index/query/QueryStringQueryBuilderTests.java
+++ b/server/src/test/java/org/elasticsearch/index/query/QueryStringQueryBuilderTests.java
@@ -40,7 +40,7 @@
import org.apache.lucene.search.PhraseQuery;
import org.apache.lucene.search.PrefixQuery;
import org.apache.lucene.search.Query;
-import org.apache.lucene.search.RegexpQuery87;
+import org.apache.lucene.search.RegexpQuery;
import org.apache.lucene.search.SynonymQuery;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TermRangeQuery;
@@ -730,8 +730,8 @@ public void testToQueryRegExpQuery() throws Exception {
Query query = queryStringQuery("/foo*bar/").defaultField(TEXT_FIELD_NAME)
.maxDeterminizedStates(5000)
.toQuery(createShardContext());
- assertThat(query, instanceOf(RegexpQuery87.class));
- RegexpQuery87 regexpQuery = (RegexpQuery87) query;
+ assertThat(query, instanceOf(RegexpQuery.class));
+ RegexpQuery regexpQuery = (RegexpQuery) query;
assertTrue(regexpQuery.toString().contains("/foo*bar/"));
}
diff --git a/server/src/test/java/org/elasticsearch/index/query/RegexpQueryBuilderTests.java b/server/src/test/java/org/elasticsearch/index/query/RegexpQueryBuilderTests.java
index 518d5edf17471..16e3be64ee2b4 100644
--- a/server/src/test/java/org/elasticsearch/index/query/RegexpQueryBuilderTests.java
+++ b/server/src/test/java/org/elasticsearch/index/query/RegexpQueryBuilderTests.java
@@ -20,9 +20,7 @@
package org.elasticsearch.index.query;
import org.apache.lucene.search.Query;
-import org.apache.lucene.search.RegExp87;
-import org.apache.lucene.search.RegexpQuery87;
-import org.apache.lucene.util.automaton.RegExp;
+import org.apache.lucene.search.RegexpQuery;
import org.elasticsearch.common.ParsingException;
import org.elasticsearch.test.AbstractQueryTestCase;
@@ -50,7 +48,7 @@ protected RegexpQueryBuilder doCreateTestQueryBuilder() {
}
if (randomBoolean()) {
query.caseInsensitive(true);
- }
+ }
if (randomBoolean()) {
query.maxDeterminizedStates(randomInt(50000));
}
@@ -82,8 +80,8 @@ private static RegexpQueryBuilder randomRegexpQuery() {
@Override
protected void doAssertLuceneQuery(RegexpQueryBuilder queryBuilder, Query query, QueryShardContext context) throws IOException {
- assertThat(query, instanceOf(RegexpQuery87.class));
- RegexpQuery87 regexpQuery = (RegexpQuery87) query;
+ assertThat(query, instanceOf(RegexpQuery.class));
+ RegexpQuery regexpQuery = (RegexpQuery) query;
String expectedFieldName = expectedFieldName( queryBuilder.fieldName());
assertThat(regexpQuery.getField(), equalTo(expectedFieldName));
@@ -152,8 +150,8 @@ public void testParseFailsWithMultipleFields() throws IOException {
"}";
e = expectThrows(ParsingException.class, () -> parseQuery(shortJson));
assertEquals("[regexp] query doesn't support multiple fields, found [user1] and [user2]", e.getMessage());
- }
-
+ }
+
public void testParseFailsWithCaseSensitive() throws IOException {
String json =
"{\n" +
@@ -166,12 +164,5 @@ public void testParseFailsWithCaseSensitive() throws IOException {
"}";
ParsingException e = expectThrows(ParsingException.class, () -> parseQuery(json));
assertEquals("[regexp] query does not support [case_insensitive] = false", e.getMessage());
- }
-
- public void testDeadCode() {
- assertTrue(RegExp87.class + " should be replaced with 8.7's "+RegExp.class,
- org.apache.lucene.util.Version.LATEST.major == 8 && org.apache.lucene.util.Version.LATEST.minor < 7);
}
-
-
}
diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/snapshots/SourceOnlySnapshot.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/snapshots/SourceOnlySnapshot.java
index 43b7643f507ea..89bdbf47d3fb4 100644
--- a/x-pack/plugin/core/src/main/java/org/elasticsearch/snapshots/SourceOnlySnapshot.java
+++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/snapshots/SourceOnlySnapshot.java
@@ -61,14 +61,13 @@
import java.util.function.Supplier;
import static org.apache.lucene.codecs.compressing.CompressingStoredFieldsWriter.FIELDS_EXTENSION;
-import static org.apache.lucene.codecs.compressing.CompressingStoredFieldsWriter.INDEX_EXTENSION_PREFIX;
-import static org.apache.lucene.codecs.compressing.FieldsIndexWriter.FIELDS_INDEX_EXTENSION_SUFFIX;
-import static org.apache.lucene.codecs.compressing.FieldsIndexWriter.FIELDS_META_EXTENSION_SUFFIX;
+import static org.apache.lucene.codecs.compressing.CompressingStoredFieldsWriter.INDEX_EXTENSION;
+import static org.apache.lucene.codecs.compressing.CompressingStoredFieldsWriter.META_EXTENSION;
public class SourceOnlySnapshot {
- private static final String FIELDS_INDEX_EXTENSION = INDEX_EXTENSION_PREFIX + FIELDS_INDEX_EXTENSION_SUFFIX;
- private static final String FIELDS_META_EXTENSION = INDEX_EXTENSION_PREFIX + FIELDS_META_EXTENSION_SUFFIX;
+ private static final String FIELDS_INDEX_EXTENSION = INDEX_EXTENSION;
+ private static final String FIELDS_META_EXTENSION = META_EXTENSION;
private final LinkedFilesDirectory targetDirectory;
private final Supplier deleteByQuerySupplier;
diff --git a/x-pack/plugin/mapper-constant-keyword/src/main/java/org/elasticsearch/xpack/constantkeyword/mapper/ConstantKeywordFieldMapper.java b/x-pack/plugin/mapper-constant-keyword/src/main/java/org/elasticsearch/xpack/constantkeyword/mapper/ConstantKeywordFieldMapper.java
index d58c4685f3c52..21e6c9254c216 100644
--- a/x-pack/plugin/mapper-constant-keyword/src/main/java/org/elasticsearch/xpack/constantkeyword/mapper/ConstantKeywordFieldMapper.java
+++ b/x-pack/plugin/mapper-constant-keyword/src/main/java/org/elasticsearch/xpack/constantkeyword/mapper/ConstantKeywordFieldMapper.java
@@ -13,12 +13,12 @@
import org.apache.lucene.search.MatchNoDocsQuery;
import org.apache.lucene.search.MultiTermQuery;
import org.apache.lucene.search.Query;
-import org.apache.lucene.search.RegExp87;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.UnicodeUtil;
import org.apache.lucene.util.automaton.Automaton;
import org.apache.lucene.util.automaton.CharacterRunAutomaton;
import org.apache.lucene.util.automaton.LevenshteinAutomata;
+import org.apache.lucene.util.automaton.RegExp;
import org.elasticsearch.common.geo.ShapeRelation;
import org.elasticsearch.common.lucene.BytesRefs;
import org.elasticsearch.common.regex.Regex;
@@ -216,7 +216,7 @@ public Query regexpQuery(String value, int syntaxFlags, int matchFlags, int maxD
return new MatchNoDocsQuery();
}
- final Automaton automaton = new RegExp87(value, syntaxFlags, matchFlags).toAutomaton(maxDeterminizedStates);
+ final Automaton automaton = new RegExp(value, syntaxFlags, matchFlags).toAutomaton(maxDeterminizedStates);
final CharacterRunAutomaton runAutomaton = new CharacterRunAutomaton(automaton);
if (runAutomaton.run(this.value)) {
return new MatchAllDocsQuery();
diff --git a/x-pack/plugin/mapper-constant-keyword/src/test/java/org/elasticsearch/xpack/constantkeyword/mapper/ConstantKeywordFieldTypeTests.java b/x-pack/plugin/mapper-constant-keyword/src/test/java/org/elasticsearch/xpack/constantkeyword/mapper/ConstantKeywordFieldTypeTests.java
index 9b5831cedf861..e5c721ef82b88 100644
--- a/x-pack/plugin/mapper-constant-keyword/src/test/java/org/elasticsearch/xpack/constantkeyword/mapper/ConstantKeywordFieldTypeTests.java
+++ b/x-pack/plugin/mapper-constant-keyword/src/test/java/org/elasticsearch/xpack/constantkeyword/mapper/ConstantKeywordFieldTypeTests.java
@@ -8,7 +8,7 @@
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.MatchNoDocsQuery;
-import org.apache.lucene.search.RegExp87;
+import org.apache.lucene.util.automaton.RegExp;
import org.elasticsearch.common.unit.Fuzziness;
import org.elasticsearch.index.mapper.FieldTypeTestCase;
import org.elasticsearch.xpack.constantkeyword.mapper.ConstantKeywordFieldMapper.ConstantKeywordFieldType;
@@ -86,9 +86,9 @@ public void testFuzzyQuery() {
public void testRegexpQuery() {
ConstantKeywordFieldType none = new ConstantKeywordFieldType("f", null);
- assertEquals(new MatchNoDocsQuery(), none.regexpQuery("f..o", RegExp87.ALL, 0, 10, null, null));
+ assertEquals(new MatchNoDocsQuery(), none.regexpQuery("f..o", RegExp.ALL, 0, 10, null, null));
ConstantKeywordFieldType ft = new ConstantKeywordFieldType("f", "foo");
- assertEquals(new MatchAllDocsQuery(), ft.regexpQuery("f.o", RegExp87.ALL, 0, 10, null, null));
- assertEquals(new MatchNoDocsQuery(), ft.regexpQuery("f..o", RegExp87.ALL, 0, 10, null, null));
+ assertEquals(new MatchAllDocsQuery(), ft.regexpQuery("f.o", RegExp.ALL, 0, 10, null, null));
+ assertEquals(new MatchNoDocsQuery(), ft.regexpQuery("f..o", RegExp.ALL, 0, 10, null, null));
}
}
diff --git a/x-pack/plugin/mapper-flattened/src/test/java/org/elasticsearch/xpack/flattened/mapper/RootFlatObjectFieldTypeTests.java b/x-pack/plugin/mapper-flattened/src/test/java/org/elasticsearch/xpack/flattened/mapper/RootFlatObjectFieldTypeTests.java
index dc61b4298b96e..d8218e3bbe4fc 100644
--- a/x-pack/plugin/mapper-flattened/src/test/java/org/elasticsearch/xpack/flattened/mapper/RootFlatObjectFieldTypeTests.java
+++ b/x-pack/plugin/mapper-flattened/src/test/java/org/elasticsearch/xpack/flattened/mapper/RootFlatObjectFieldTypeTests.java
@@ -10,7 +10,7 @@
import org.apache.lucene.search.DocValuesFieldExistsQuery;
import org.apache.lucene.search.FuzzyQuery;
import org.apache.lucene.search.Query;
-import org.apache.lucene.search.RegexpQuery87;
+import org.apache.lucene.search.RegexpQuery;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TermRangeQuery;
import org.apache.lucene.search.WildcardQuery;
@@ -96,7 +96,7 @@ public void testRangeQuery() {
public void testRegexpQuery() {
RootFlatObjectFieldType ft = createDefaultFieldType();
- Query expected = new RegexpQuery87(new Term("field", "val.*"));
+ Query expected = new RegexpQuery(new Term("field", "val.*"));
Query actual = ft.regexpQuery("val.*", 0, 0, 10, null, MOCK_QSC);
assertEquals(expected, actual);
diff --git a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/query/StringScriptFieldRegexpQueryTests.java b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/query/StringScriptFieldRegexpQueryTests.java
index 2f2a28952b4f8..21423d20917fe 100644
--- a/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/query/StringScriptFieldRegexpQueryTests.java
+++ b/x-pack/plugin/runtime-fields/src/test/java/org/elasticsearch/xpack/runtimefields/query/StringScriptFieldRegexpQueryTests.java
@@ -9,6 +9,7 @@
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.automaton.ByteRunAutomaton;
import org.apache.lucene.util.automaton.Operations;
+import org.apache.lucene.util.automaton.RegExp;
import org.elasticsearch.script.Script;
import java.util.List;
@@ -24,7 +25,7 @@ protected StringScriptFieldRegexpQuery createTestInstance() {
leafFactory,
randomAlphaOfLength(5),
randomAlphaOfLength(6),
- randomInt(0xFFFF),
+ randomInt(RegExp.ALL),
Operations.DEFAULT_MAX_DETERMINIZED_STATES
);
}
diff --git a/x-pack/plugin/sql/sql-action/licenses/lucene-core-8.6.2.jar.sha1 b/x-pack/plugin/sql/sql-action/licenses/lucene-core-8.6.2.jar.sha1
deleted file mode 100644
index 72e55eb897d5b..0000000000000
--- a/x-pack/plugin/sql/sql-action/licenses/lucene-core-8.6.2.jar.sha1
+++ /dev/null
@@ -1 +0,0 @@
-de97930c2f5242124e52579eb3d23722e13f0f9d
\ No newline at end of file
diff --git a/x-pack/plugin/sql/sql-action/licenses/lucene-core-8.7.0-snapshot-61ea26a.jar.sha1 b/x-pack/plugin/sql/sql-action/licenses/lucene-core-8.7.0-snapshot-61ea26a.jar.sha1
new file mode 100644
index 0000000000000..dedfacd1be804
--- /dev/null
+++ b/x-pack/plugin/sql/sql-action/licenses/lucene-core-8.7.0-snapshot-61ea26a.jar.sha1
@@ -0,0 +1 @@
+331c1607af5fea2251e8c3cd6a0bce04f3ec2bc6
\ No newline at end of file
diff --git a/x-pack/plugin/wildcard/src/main/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapper.java b/x-pack/plugin/wildcard/src/main/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapper.java
index 67152510e312d..1d208bc69a214 100644
--- a/x-pack/plugin/wildcard/src/main/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapper.java
+++ b/x-pack/plugin/wildcard/src/main/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapper.java
@@ -29,13 +29,13 @@
import org.apache.lucene.search.MultiTermQuery.RewriteMethod;
import org.apache.lucene.search.PrefixQuery;
import org.apache.lucene.search.Query;
-import org.apache.lucene.search.RegExp87;
-import org.apache.lucene.search.RegExp87.Kind;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TermRangeQuery;
import org.apache.lucene.search.WildcardQuery;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.automaton.Automaton;
+import org.apache.lucene.util.automaton.RegExp;
+import org.apache.lucene.util.automaton.RegExp.Kind;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.geo.ShapeRelation;
import org.elasticsearch.common.lucene.BytesRefs;
@@ -301,7 +301,7 @@ public Query regexpQuery(String value, int syntaxFlags, int matchFlags, int maxD
return new MatchNoDocsQuery();
}
- RegExp87 ngramRegex = new RegExp87(addLineEndChars(toLowerCase(value)), syntaxFlags, matchFlags);
+ RegExp ngramRegex = new RegExp(addLineEndChars(toLowerCase(value)), syntaxFlags, matchFlags);
Query approxBooleanQuery = toApproximationQuery(ngramRegex);
Query approxNgramQuery = rewriteBoolToNgramQuery(approxBooleanQuery);
@@ -312,7 +312,7 @@ public Query regexpQuery(String value, int syntaxFlags, int matchFlags, int maxD
return existsQuery(context);
}
Supplier deferredAutomatonSupplier = ()-> {
- RegExp87 regex = new RegExp87(value, syntaxFlags, matchFlags);
+ RegExp regex = new RegExp(value, syntaxFlags, matchFlags);
return regex.toAutomaton(maxDeterminizedStates);
};
@@ -341,7 +341,7 @@ public Query regexpQuery(String value, int syntaxFlags, int matchFlags, int maxD
// * If an expression resolves to a RegExpQuery eg ?? then only the verification
// query is run.
// * Anything else is a concrete query that should be run on the ngram index.
- public static Query toApproximationQuery(RegExp87 r) throws IllegalArgumentException {
+ public static Query toApproximationQuery(RegExp r) throws IllegalArgumentException {
Query result = null;
switch (r.kind) {
case REGEXP_UNION:
@@ -402,7 +402,7 @@ public static Query toApproximationQuery(RegExp87 r) throws IllegalArgumentExcep
return result;
}
- private static Query createConcatenationQuery(RegExp87 r) {
+ private static Query createConcatenationQuery(RegExp r) {
// Create ANDs of expressions plus collapse consecutive TermQuerys into single longer ones
ArrayList queries = new ArrayList<>();
findLeaves(r.exp1, Kind.REGEXP_CONCATENATION, queries);
@@ -433,7 +433,7 @@ private static Query createConcatenationQuery(RegExp87 r) {
}
- private static Query createUnionQuery(RegExp87 r) {
+ private static Query createUnionQuery(RegExp r) {
// Create an OR of clauses
ArrayList queries = new ArrayList<>();
findLeaves(r.exp1, Kind.REGEXP_UNION, queries);
@@ -460,7 +460,7 @@ private static Query createUnionQuery(RegExp87 r) {
return new MatchAllButRequireVerificationQuery();
}
- private static void findLeaves(RegExp87 exp, Kind kind, List queries) {
+ private static void findLeaves(RegExp exp, Kind kind, List queries) {
if (exp.kind == kind) {
findLeaves(exp.exp1, kind, queries);
findLeaves( exp.exp2, kind, queries);
diff --git a/x-pack/plugin/wildcard/src/test/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapperTests.java b/x-pack/plugin/wildcard/src/test/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapperTests.java
index f137dac9262d5..e69bf6c7f0c19 100644
--- a/x-pack/plugin/wildcard/src/test/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapperTests.java
+++ b/x-pack/plugin/wildcard/src/test/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapperTests.java
@@ -26,7 +26,6 @@
import org.apache.lucene.search.MatchAllDocsQuery;
import org.apache.lucene.search.MatchNoDocsQuery;
import org.apache.lucene.search.Query;
-import org.apache.lucene.search.RegExp87;
import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.Sort;
import org.apache.lucene.search.SortField;
@@ -39,6 +38,7 @@
import org.apache.lucene.util.automaton.Automaton;
import org.apache.lucene.util.automaton.ByteRunAutomaton;
//import org.apache.lucene.util.automaton.RegExp;
+import org.apache.lucene.util.automaton.RegExp;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.TriFunction;
@@ -171,7 +171,7 @@ public void testTooBigQueryField() throws IOException {
assertThat(wildcardFieldTopDocs.totalHits.value, equalTo(0L));
// Test regexp query
- wildcardFieldQuery = wildcardFieldType.fieldType().regexpQuery(queryString, RegExp87.ALL, 0, 20000, null, MOCK_QSC);
+ wildcardFieldQuery = wildcardFieldType.fieldType().regexpQuery(queryString, RegExp.ALL, 0, 20000, null, MOCK_QSC);
wildcardFieldTopDocs = searcher.search(wildcardFieldQuery, 10, Sort.INDEXORDER);
assertThat(wildcardFieldTopDocs.totalHits.value, equalTo(0L));
@@ -228,8 +228,8 @@ public void testSearchResultsVersusKeywordField() throws IOException {
break;
case 1:
pattern = getRandomRegexPattern(values);
- wildcardFieldQuery = wildcardFieldType.fieldType().regexpQuery(pattern, RegExp87.ALL, 0, 20000, null, MOCK_QSC);
- keywordFieldQuery = keywordFieldType.fieldType().regexpQuery(pattern, RegExp87.ALL, 0,20000, null, MOCK_QSC);
+ wildcardFieldQuery = wildcardFieldType.fieldType().regexpQuery(pattern, RegExp.ALL, 0, 20000, null, MOCK_QSC);
+ keywordFieldQuery = keywordFieldType.fieldType().regexpQuery(pattern, RegExp.ALL, 0,20000, null, MOCK_QSC);
break;
case 2:
pattern = randomABString(5);
@@ -382,12 +382,12 @@ public void testRegexAcceleration() throws IOException, ParseException {
// All these expressions should rewrite to a match all with no verification step required at all
String superfastRegexes[]= { ".*", "...*..", "(foo|bar|.*)", "@"};
for (String regex : superfastRegexes) {
- Query wildcardFieldQuery = wildcardFieldType.fieldType().regexpQuery(regex, RegExp87.ALL, 0, 20000, null, MOCK_QSC);
+ Query wildcardFieldQuery = wildcardFieldType.fieldType().regexpQuery(regex, RegExp.ALL, 0, 20000, null, MOCK_QSC);
assertTrue(wildcardFieldQuery instanceof DocValuesFieldExistsQuery);
}
String matchNoDocsRegexes[]= { ""};
for (String regex : matchNoDocsRegexes) {
- Query wildcardFieldQuery = wildcardFieldType.fieldType().regexpQuery(regex, RegExp87.ALL, 0, 20000, null, MOCK_QSC);
+ Query wildcardFieldQuery = wildcardFieldType.fieldType().regexpQuery(regex, RegExp.ALL, 0, 20000, null, MOCK_QSC);
assertTrue(wildcardFieldQuery instanceof MatchNoDocsQuery);
}
@@ -407,7 +407,7 @@ public void testRegexAcceleration() throws IOException, ParseException {
for (String[] test : acceleratedTests) {
String regex = test[0];
String expectedAccelerationQueryString = test[1].replaceAll("_", ""+WildcardFieldMapper.TOKEN_START_OR_END_CHAR);
- Query wildcardFieldQuery = wildcardFieldType.fieldType().regexpQuery(regex, RegExp87.ALL, 0, 20000, null, MOCK_QSC);
+ Query wildcardFieldQuery = wildcardFieldType.fieldType().regexpQuery(regex, RegExp.ALL, 0, 20000, null, MOCK_QSC);
testExpectedAccelerationQuery(regex, wildcardFieldQuery, expectedAccelerationQueryString);
}
@@ -415,7 +415,7 @@ public void testRegexAcceleration() throws IOException, ParseException {
// TODO we can possibly improve on some of these
String matchAllButVerifyTests[]= { "..", "(a)?","(a|b){0,3}", "((foo)?|(foo|bar)?)", "@&~(abc.+)", "aaa.+&.+bbb"};
for (String regex : matchAllButVerifyTests) {
- Query wildcardFieldQuery = wildcardFieldType.fieldType().regexpQuery(regex, RegExp87.ALL, 0, 20000, null, MOCK_QSC);
+ Query wildcardFieldQuery = wildcardFieldType.fieldType().regexpQuery(regex, RegExp.ALL, 0, 20000, null, MOCK_QSC);
assertTrue(regex +" was not a pure verify query " +formatQuery(wildcardFieldQuery),
wildcardFieldQuery instanceof AutomatonQueryOnBinaryDv);
}
@@ -431,7 +431,7 @@ public void testRegexAcceleration() throws IOException, ParseException {
for (String[] test : suboptimalTests) {
String regex = test[0];
String expectedAccelerationQueryString = test[1].replaceAll("_", ""+WildcardFieldMapper.TOKEN_START_OR_END_CHAR);
- Query wildcardFieldQuery = wildcardFieldType.fieldType().regexpQuery(regex, RegExp87.ALL, 0, 20000, null, MOCK_QSC);
+ Query wildcardFieldQuery = wildcardFieldType.fieldType().regexpQuery(regex, RegExp.ALL, 0, 20000, null, MOCK_QSC);
testExpectedAccelerationQuery(regex, wildcardFieldQuery, expectedAccelerationQueryString);
}
@@ -770,7 +770,7 @@ protected String convertToRandomRegex(String randomValue) {
}
//Assert our randomly generated regex actually matches the provided raw input.
- RegExp87 regex = new RegExp87(result.toString());
+ RegExp regex = new RegExp(result.toString());
Automaton automaton = regex.toAutomaton();
ByteRunAutomaton bytesMatcher = new ByteRunAutomaton(automaton);
BytesRef br = new BytesRef(randomValue);