diff --git a/buildSrc/version.properties b/buildSrc/version.properties index f7d95c5b9a79e..006004ffacaba 100644 --- a/buildSrc/version.properties +++ b/buildSrc/version.properties @@ -1,5 +1,5 @@ elasticsearch = 8.0.0 -lucene = 8.6.2 +lucene = 8.7.0-snapshot-61ea26a bundled_jdk_vendor = adoptopenjdk bundled_jdk = 14.0.1+7 diff --git a/docs/Versions.asciidoc b/docs/Versions.asciidoc index 0c092dbe5f194..5c978bbbbd405 100644 --- a/docs/Versions.asciidoc +++ b/docs/Versions.asciidoc @@ -1,8 +1,8 @@ include::{docs-root}/shared/versions/stack/{source_branch}.asciidoc[] -:lucene_version: 8.6.2 -:lucene_version_path: 8_6_2 +:lucene_version: 8.7.0 +:lucene_version_path: 8_7_0 :jdk: 11.0.2 :jdk_major: 11 :build_flavor: default diff --git a/modules/lang-expression/licenses/lucene-expressions-8.6.2.jar.sha1 b/modules/lang-expression/licenses/lucene-expressions-8.6.2.jar.sha1 deleted file mode 100644 index 121513c5d36f5..0000000000000 --- a/modules/lang-expression/licenses/lucene-expressions-8.6.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -2f8451c08cd6d19ecacea5f35db2f94014a3a423 \ No newline at end of file diff --git a/modules/lang-expression/licenses/lucene-expressions-8.7.0-snapshot-61ea26a.jar.sha1 b/modules/lang-expression/licenses/lucene-expressions-8.7.0-snapshot-61ea26a.jar.sha1 new file mode 100644 index 0000000000000..b25454c770050 --- /dev/null +++ b/modules/lang-expression/licenses/lucene-expressions-8.7.0-snapshot-61ea26a.jar.sha1 @@ -0,0 +1 @@ +d952f8254b64ff63b1846233371511073736e77d \ No newline at end of file diff --git a/plugins/analysis-icu/licenses/lucene-analyzers-icu-8.6.2.jar.sha1 b/plugins/analysis-icu/licenses/lucene-analyzers-icu-8.6.2.jar.sha1 deleted file mode 100644 index d85d18b01b1c2..0000000000000 --- a/plugins/analysis-icu/licenses/lucene-analyzers-icu-8.6.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -75b90e16b9f0773a5fde05715f07f5a0b8a66658 \ No newline at end of file diff --git a/plugins/analysis-icu/licenses/lucene-analyzers-icu-8.7.0-snapshot-61ea26a.jar.sha1 b/plugins/analysis-icu/licenses/lucene-analyzers-icu-8.7.0-snapshot-61ea26a.jar.sha1 new file mode 100644 index 0000000000000..cb2e4c1f0b56b --- /dev/null +++ b/plugins/analysis-icu/licenses/lucene-analyzers-icu-8.7.0-snapshot-61ea26a.jar.sha1 @@ -0,0 +1 @@ +f69abfe7fcdb8a9c1a929f5e7292924bbd38557a \ No newline at end of file diff --git a/plugins/analysis-kuromoji/licenses/lucene-analyzers-kuromoji-8.6.2.jar.sha1 b/plugins/analysis-kuromoji/licenses/lucene-analyzers-kuromoji-8.6.2.jar.sha1 deleted file mode 100644 index 1bdb90e622b59..0000000000000 --- a/plugins/analysis-kuromoji/licenses/lucene-analyzers-kuromoji-8.6.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -665b1e0480983dd2e2996996a104cf05dca783c9 \ No newline at end of file diff --git a/plugins/analysis-kuromoji/licenses/lucene-analyzers-kuromoji-8.7.0-snapshot-61ea26a.jar.sha1 b/plugins/analysis-kuromoji/licenses/lucene-analyzers-kuromoji-8.7.0-snapshot-61ea26a.jar.sha1 new file mode 100644 index 0000000000000..0f78c23f59475 --- /dev/null +++ b/plugins/analysis-kuromoji/licenses/lucene-analyzers-kuromoji-8.7.0-snapshot-61ea26a.jar.sha1 @@ -0,0 +1 @@ +005c312e96d1c9d47fd3bf0980c810c30c497500 \ No newline at end of file diff --git a/plugins/analysis-nori/licenses/lucene-analyzers-nori-8.6.2.jar.sha1 b/plugins/analysis-nori/licenses/lucene-analyzers-nori-8.6.2.jar.sha1 deleted file mode 100644 index daafadec190a2..0000000000000 --- a/plugins/analysis-nori/licenses/lucene-analyzers-nori-8.6.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -f3f001555ee4719adf4f8ce4d2bfe3de4ebd1f35 \ No newline at end of file diff --git a/plugins/analysis-nori/licenses/lucene-analyzers-nori-8.7.0-snapshot-61ea26a.jar.sha1 b/plugins/analysis-nori/licenses/lucene-analyzers-nori-8.7.0-snapshot-61ea26a.jar.sha1 new file mode 100644 index 0000000000000..c54ad2efc3435 --- /dev/null +++ b/plugins/analysis-nori/licenses/lucene-analyzers-nori-8.7.0-snapshot-61ea26a.jar.sha1 @@ -0,0 +1 @@ +b0fb357b731fa483f747e2107c2e01b75160af72 \ No newline at end of file diff --git a/plugins/analysis-phonetic/licenses/lucene-analyzers-phonetic-8.6.2.jar.sha1 b/plugins/analysis-phonetic/licenses/lucene-analyzers-phonetic-8.6.2.jar.sha1 deleted file mode 100644 index 21d5c129683d5..0000000000000 --- a/plugins/analysis-phonetic/licenses/lucene-analyzers-phonetic-8.6.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -a3676e5a7fb6ed20d0d641f893e3e7b1bda824ea \ No newline at end of file diff --git a/plugins/analysis-phonetic/licenses/lucene-analyzers-phonetic-8.7.0-snapshot-61ea26a.jar.sha1 b/plugins/analysis-phonetic/licenses/lucene-analyzers-phonetic-8.7.0-snapshot-61ea26a.jar.sha1 new file mode 100644 index 0000000000000..3f44d5e30521c --- /dev/null +++ b/plugins/analysis-phonetic/licenses/lucene-analyzers-phonetic-8.7.0-snapshot-61ea26a.jar.sha1 @@ -0,0 +1 @@ +689b5f0e3371d0709765c9ba7fc21042cf41754d \ No newline at end of file diff --git a/plugins/analysis-smartcn/licenses/lucene-analyzers-smartcn-8.6.2.jar.sha1 b/plugins/analysis-smartcn/licenses/lucene-analyzers-smartcn-8.6.2.jar.sha1 deleted file mode 100644 index 9a967839c5342..0000000000000 --- a/plugins/analysis-smartcn/licenses/lucene-analyzers-smartcn-8.6.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -6213af5b0dc92962cf9adc05a14f04682b9bbf15 \ No newline at end of file diff --git a/plugins/analysis-smartcn/licenses/lucene-analyzers-smartcn-8.7.0-snapshot-61ea26a.jar.sha1 b/plugins/analysis-smartcn/licenses/lucene-analyzers-smartcn-8.7.0-snapshot-61ea26a.jar.sha1 new file mode 100644 index 0000000000000..e19f7bd10c747 --- /dev/null +++ b/plugins/analysis-smartcn/licenses/lucene-analyzers-smartcn-8.7.0-snapshot-61ea26a.jar.sha1 @@ -0,0 +1 @@ +5b0a0c7a88076ab8ee21d0b3781fae8d8353da84 \ No newline at end of file diff --git a/plugins/analysis-stempel/licenses/lucene-analyzers-stempel-8.6.2.jar.sha1 b/plugins/analysis-stempel/licenses/lucene-analyzers-stempel-8.6.2.jar.sha1 deleted file mode 100644 index 508b82bb8e999..0000000000000 --- a/plugins/analysis-stempel/licenses/lucene-analyzers-stempel-8.6.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -0cb86dd6a32c867802fe5604dbab6e0fd84aa9fc \ No newline at end of file diff --git a/plugins/analysis-stempel/licenses/lucene-analyzers-stempel-8.7.0-snapshot-61ea26a.jar.sha1 b/plugins/analysis-stempel/licenses/lucene-analyzers-stempel-8.7.0-snapshot-61ea26a.jar.sha1 new file mode 100644 index 0000000000000..5a41b9b92160c --- /dev/null +++ b/plugins/analysis-stempel/licenses/lucene-analyzers-stempel-8.7.0-snapshot-61ea26a.jar.sha1 @@ -0,0 +1 @@ +8cbea549bf71ca41bfd6ed985d188ee74d6e9098 \ No newline at end of file diff --git a/plugins/analysis-ukrainian/licenses/lucene-analyzers-morfologik-8.6.2.jar.sha1 b/plugins/analysis-ukrainian/licenses/lucene-analyzers-morfologik-8.6.2.jar.sha1 deleted file mode 100644 index 1d1557953571f..0000000000000 --- a/plugins/analysis-ukrainian/licenses/lucene-analyzers-morfologik-8.6.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -3e44b8d571e18a67abb9e3bc941cd1a7cc4203c8 \ No newline at end of file diff --git a/plugins/analysis-ukrainian/licenses/lucene-analyzers-morfologik-8.7.0-snapshot-61ea26a.jar.sha1 b/plugins/analysis-ukrainian/licenses/lucene-analyzers-morfologik-8.7.0-snapshot-61ea26a.jar.sha1 new file mode 100644 index 0000000000000..62c7657c47291 --- /dev/null +++ b/plugins/analysis-ukrainian/licenses/lucene-analyzers-morfologik-8.7.0-snapshot-61ea26a.jar.sha1 @@ -0,0 +1 @@ +05cccc203ace5a4af42c77fb32b235c94f8ceb5a \ No newline at end of file diff --git a/server/licenses/lucene-analyzers-common-8.6.2.jar.sha1 b/server/licenses/lucene-analyzers-common-8.6.2.jar.sha1 deleted file mode 100644 index 77847d0ebd758..0000000000000 --- a/server/licenses/lucene-analyzers-common-8.6.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -c4c58571911464138b7ad8881a4319cb0d0ce504 \ No newline at end of file diff --git a/server/licenses/lucene-analyzers-common-8.7.0-snapshot-61ea26a.jar.sha1 b/server/licenses/lucene-analyzers-common-8.7.0-snapshot-61ea26a.jar.sha1 new file mode 100644 index 0000000000000..10601013447c5 --- /dev/null +++ b/server/licenses/lucene-analyzers-common-8.7.0-snapshot-61ea26a.jar.sha1 @@ -0,0 +1 @@ +2191c2c337bbc483c1bce0d7b35f0e00bece50ab \ No newline at end of file diff --git a/server/licenses/lucene-backward-codecs-8.6.2.jar.sha1 b/server/licenses/lucene-backward-codecs-8.6.2.jar.sha1 deleted file mode 100644 index 5ba097b1803ca..0000000000000 --- a/server/licenses/lucene-backward-codecs-8.6.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -3719b09652d0c9de87de529060d9c2ce527f929c \ No newline at end of file diff --git a/server/licenses/lucene-backward-codecs-8.7.0-snapshot-61ea26a.jar.sha1 b/server/licenses/lucene-backward-codecs-8.7.0-snapshot-61ea26a.jar.sha1 new file mode 100644 index 0000000000000..4c1536414f5f3 --- /dev/null +++ b/server/licenses/lucene-backward-codecs-8.7.0-snapshot-61ea26a.jar.sha1 @@ -0,0 +1 @@ +d9d677d9b01528b984c722dd30fb1ceca9f601b7 \ No newline at end of file diff --git a/server/licenses/lucene-core-8.6.2.jar.sha1 b/server/licenses/lucene-core-8.6.2.jar.sha1 deleted file mode 100644 index 72e55eb897d5b..0000000000000 --- a/server/licenses/lucene-core-8.6.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -de97930c2f5242124e52579eb3d23722e13f0f9d \ No newline at end of file diff --git a/server/licenses/lucene-core-8.7.0-snapshot-61ea26a.jar.sha1 b/server/licenses/lucene-core-8.7.0-snapshot-61ea26a.jar.sha1 new file mode 100644 index 0000000000000..dedfacd1be804 --- /dev/null +++ b/server/licenses/lucene-core-8.7.0-snapshot-61ea26a.jar.sha1 @@ -0,0 +1 @@ +331c1607af5fea2251e8c3cd6a0bce04f3ec2bc6 \ No newline at end of file diff --git a/server/licenses/lucene-grouping-8.6.2.jar.sha1 b/server/licenses/lucene-grouping-8.6.2.jar.sha1 deleted file mode 100644 index 1b47357855824..0000000000000 --- a/server/licenses/lucene-grouping-8.6.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -d6fd5936f99ab50622e75ba6dacff97090cb62e1 \ No newline at end of file diff --git a/server/licenses/lucene-grouping-8.7.0-snapshot-61ea26a.jar.sha1 b/server/licenses/lucene-grouping-8.7.0-snapshot-61ea26a.jar.sha1 new file mode 100644 index 0000000000000..e1710dbfbc14c --- /dev/null +++ b/server/licenses/lucene-grouping-8.7.0-snapshot-61ea26a.jar.sha1 @@ -0,0 +1 @@ +d5fa5c12ccb43629d79591c0079b5648a200e3cb \ No newline at end of file diff --git a/server/licenses/lucene-highlighter-8.6.2.jar.sha1 b/server/licenses/lucene-highlighter-8.6.2.jar.sha1 deleted file mode 100644 index 21a0a9d90b1ea..0000000000000 --- a/server/licenses/lucene-highlighter-8.6.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -275ce757580877efb9370452c282a1de4d10fd3e \ No newline at end of file diff --git a/server/licenses/lucene-highlighter-8.7.0-snapshot-61ea26a.jar.sha1 b/server/licenses/lucene-highlighter-8.7.0-snapshot-61ea26a.jar.sha1 new file mode 100644 index 0000000000000..a031cf52d2726 --- /dev/null +++ b/server/licenses/lucene-highlighter-8.7.0-snapshot-61ea26a.jar.sha1 @@ -0,0 +1 @@ +3e24abaa4ad85106b22dbdbd61756bda369c6d04 \ No newline at end of file diff --git a/server/licenses/lucene-join-8.6.2.jar.sha1 b/server/licenses/lucene-join-8.6.2.jar.sha1 deleted file mode 100644 index 5cd44dbab1947..0000000000000 --- a/server/licenses/lucene-join-8.6.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -8f7e21a00095e0ebed741e2ee425da8019b47b6b \ No newline at end of file diff --git a/server/licenses/lucene-join-8.7.0-snapshot-61ea26a.jar.sha1 b/server/licenses/lucene-join-8.7.0-snapshot-61ea26a.jar.sha1 new file mode 100644 index 0000000000000..86cd6efa45d97 --- /dev/null +++ b/server/licenses/lucene-join-8.7.0-snapshot-61ea26a.jar.sha1 @@ -0,0 +1 @@ +13b6769b7a956bc4d1b4e162a45aea9a8064948c \ No newline at end of file diff --git a/server/licenses/lucene-memory-8.6.2.jar.sha1 b/server/licenses/lucene-memory-8.6.2.jar.sha1 deleted file mode 100644 index ab4c22c272836..0000000000000 --- a/server/licenses/lucene-memory-8.6.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -75412c308ff3d9f2bf45248538b9806ce624cc3d \ No newline at end of file diff --git a/server/licenses/lucene-memory-8.7.0-snapshot-61ea26a.jar.sha1 b/server/licenses/lucene-memory-8.7.0-snapshot-61ea26a.jar.sha1 new file mode 100644 index 0000000000000..cba647e98cc6a --- /dev/null +++ b/server/licenses/lucene-memory-8.7.0-snapshot-61ea26a.jar.sha1 @@ -0,0 +1 @@ +8f17e777d3782bbec1036770e40823a867a72586 \ No newline at end of file diff --git a/server/licenses/lucene-misc-8.6.2.jar.sha1 b/server/licenses/lucene-misc-8.6.2.jar.sha1 deleted file mode 100644 index d2182996e96ac..0000000000000 --- a/server/licenses/lucene-misc-8.6.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -1072a1d3b3c6ffa40116a88c267bfa8523ccc166 \ No newline at end of file diff --git a/server/licenses/lucene-misc-8.7.0-snapshot-61ea26a.jar.sha1 b/server/licenses/lucene-misc-8.7.0-snapshot-61ea26a.jar.sha1 new file mode 100644 index 0000000000000..61389c0e1b8b8 --- /dev/null +++ b/server/licenses/lucene-misc-8.7.0-snapshot-61ea26a.jar.sha1 @@ -0,0 +1 @@ +3ddfc214dc0ea4b39532f2a3800181d1142afa02 \ No newline at end of file diff --git a/server/licenses/lucene-queries-8.6.2.jar.sha1 b/server/licenses/lucene-queries-8.6.2.jar.sha1 deleted file mode 100644 index 9ef304478601b..0000000000000 --- a/server/licenses/lucene-queries-8.6.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -f1edd4d4645d7e8ba07de3302a272123f061cbb5 \ No newline at end of file diff --git a/server/licenses/lucene-queries-8.7.0-snapshot-61ea26a.jar.sha1 b/server/licenses/lucene-queries-8.7.0-snapshot-61ea26a.jar.sha1 new file mode 100644 index 0000000000000..3c3e44bdcbc45 --- /dev/null +++ b/server/licenses/lucene-queries-8.7.0-snapshot-61ea26a.jar.sha1 @@ -0,0 +1 @@ +b1b5e237cdf3a37f78dfecacdd13373427c6c2d6 \ No newline at end of file diff --git a/server/licenses/lucene-queryparser-8.6.2.jar.sha1 b/server/licenses/lucene-queryparser-8.6.2.jar.sha1 deleted file mode 100644 index aa5cfa016c507..0000000000000 --- a/server/licenses/lucene-queryparser-8.6.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -27c206ac7cd7ba7b3edb176c781718c99efb14e2 \ No newline at end of file diff --git a/server/licenses/lucene-queryparser-8.7.0-snapshot-61ea26a.jar.sha1 b/server/licenses/lucene-queryparser-8.7.0-snapshot-61ea26a.jar.sha1 new file mode 100644 index 0000000000000..aff2a1e8d3851 --- /dev/null +++ b/server/licenses/lucene-queryparser-8.7.0-snapshot-61ea26a.jar.sha1 @@ -0,0 +1 @@ +115b85c09a0c0d6bd4213d100fbe2ac2494ff5e1 \ No newline at end of file diff --git a/server/licenses/lucene-sandbox-8.6.2.jar.sha1 b/server/licenses/lucene-sandbox-8.6.2.jar.sha1 deleted file mode 100644 index f1b932a5ca312..0000000000000 --- a/server/licenses/lucene-sandbox-8.6.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -82d432972fecbeb3713329eca9240fd2bb322bd5 \ No newline at end of file diff --git a/server/licenses/lucene-sandbox-8.7.0-snapshot-61ea26a.jar.sha1 b/server/licenses/lucene-sandbox-8.7.0-snapshot-61ea26a.jar.sha1 new file mode 100644 index 0000000000000..41bb226ac3a97 --- /dev/null +++ b/server/licenses/lucene-sandbox-8.7.0-snapshot-61ea26a.jar.sha1 @@ -0,0 +1 @@ +88c87545785f724c7a9babcf58818ae68c287423 \ No newline at end of file diff --git a/server/licenses/lucene-spatial-extras-8.6.2.jar.sha1 b/server/licenses/lucene-spatial-extras-8.6.2.jar.sha1 deleted file mode 100644 index 7749f26978271..0000000000000 --- a/server/licenses/lucene-spatial-extras-8.6.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -9b145bd48c34e4a478f1e090a8424a3974ee23f1 \ No newline at end of file diff --git a/server/licenses/lucene-spatial-extras-8.7.0-snapshot-61ea26a.jar.sha1 b/server/licenses/lucene-spatial-extras-8.7.0-snapshot-61ea26a.jar.sha1 new file mode 100644 index 0000000000000..88951a1af9e5a --- /dev/null +++ b/server/licenses/lucene-spatial-extras-8.7.0-snapshot-61ea26a.jar.sha1 @@ -0,0 +1 @@ +e43bf5d798b5b12c2f4f815df0c1b238d02d1795 \ No newline at end of file diff --git a/server/licenses/lucene-spatial3d-8.6.2.jar.sha1 b/server/licenses/lucene-spatial3d-8.6.2.jar.sha1 deleted file mode 100644 index 11cb3c8042fba..0000000000000 --- a/server/licenses/lucene-spatial3d-8.6.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -e9b93e2f6c5cdb74332b6b9aada4a190f20d45c3 \ No newline at end of file diff --git a/server/licenses/lucene-spatial3d-8.7.0-snapshot-61ea26a.jar.sha1 b/server/licenses/lucene-spatial3d-8.7.0-snapshot-61ea26a.jar.sha1 new file mode 100644 index 0000000000000..a41eea5e54d18 --- /dev/null +++ b/server/licenses/lucene-spatial3d-8.7.0-snapshot-61ea26a.jar.sha1 @@ -0,0 +1 @@ +a957497d9bb5c0c842703bbaa452125f462de309 \ No newline at end of file diff --git a/server/licenses/lucene-suggest-8.6.2.jar.sha1 b/server/licenses/lucene-suggest-8.6.2.jar.sha1 deleted file mode 100644 index 0bb333aabce79..0000000000000 --- a/server/licenses/lucene-suggest-8.6.2.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -1ffe015e1f765ec0e8aaccd3b82d7578584aebbf \ No newline at end of file diff --git a/server/licenses/lucene-suggest-8.7.0-snapshot-61ea26a.jar.sha1 b/server/licenses/lucene-suggest-8.7.0-snapshot-61ea26a.jar.sha1 new file mode 100644 index 0000000000000..993875a73a467 --- /dev/null +++ b/server/licenses/lucene-suggest-8.7.0-snapshot-61ea26a.jar.sha1 @@ -0,0 +1 @@ +c8978f546b65eefe4647f3bddcfffe2c574d0c84 \ No newline at end of file diff --git a/server/src/main/java/org/apache/lucene/search/RegExp87.java b/server/src/main/java/org/apache/lucene/search/RegExp87.java deleted file mode 100644 index 00d77efbacf36..0000000000000 --- a/server/src/main/java/org/apache/lucene/search/RegExp87.java +++ /dev/null @@ -1,1074 +0,0 @@ -/* - * dk.brics.automaton - * - * Copyright (c) 2001-2009 Anders Moeller - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -package org.apache.lucene.search; - -import org.apache.lucene.util.automaton.Automata; -import org.apache.lucene.util.automaton.Automaton; -import org.apache.lucene.util.automaton.AutomatonProvider; -import org.apache.lucene.util.automaton.MinimizationOperations; -import org.apache.lucene.util.automaton.Operations; -import org.apache.lucene.util.automaton.RegExp; -import org.apache.lucene.util.automaton.TooComplexToDeterminizeException; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - - -/** - * Copy of Lucene 8.7's forthcoming RegExp class brought forward for - * case insensitive search feature. - * - * @deprecated Use the RegExp object coming in Lucene 8.7 when it ships - */ -@Deprecated -public class RegExp87 { - - /** - * The type of expression represented by a RegExp node. - */ - public enum Kind { - /** The union of two expressions */ - REGEXP_UNION, - /** A sequence of two expressions */ - REGEXP_CONCATENATION, - /** The intersection of two expressions */ - REGEXP_INTERSECTION, - /** An optional expression */ - REGEXP_OPTIONAL, - /** An expression that repeats */ - REGEXP_REPEAT, - /** An expression that repeats a minimum number of times*/ - REGEXP_REPEAT_MIN, - /** An expression that repeats a minimum and maximum number of times*/ - REGEXP_REPEAT_MINMAX, - /** The complement of an expression */ - REGEXP_COMPLEMENT, - /** A Character */ - REGEXP_CHAR, - /** A Character range*/ - REGEXP_CHAR_RANGE, - /** Any Character allowed*/ - REGEXP_ANYCHAR, - /** An empty expression*/ - REGEXP_EMPTY, - /** A string expression*/ - REGEXP_STRING, - /** Any string allowed */ - REGEXP_ANYSTRING, - /** An Automaton expression*/ - REGEXP_AUTOMATON, - /** An Interval expression */ - REGEXP_INTERVAL, - /** An expression for a pre-defined class e.g. \w */ - REGEXP_PRE_CLASS - } - - //----- Syntax flags ( <= 0xff ) ------ - /** - * Syntax flag, enables intersection (&). - */ - public static final int INTERSECTION = 0x0001; - - /** - * Syntax flag, enables complement (~). - */ - public static final int COMPLEMENT = 0x0002; - - /** - * Syntax flag, enables empty language (#). - */ - public static final int EMPTY = 0x0004; - - /** - * Syntax flag, enables anystring (@). - */ - public static final int ANYSTRING = 0x0008; - - /** - * Syntax flag, enables named automata (<identifier>). - */ - public static final int AUTOMATON = 0x0010; - - /** - * Syntax flag, enables numerical intervals ( - * <n-m>). - */ - public static final int INTERVAL = 0x0020; - - /** - * Syntax flag, enables all optional regexp syntax. - */ - public static final int ALL = 0xff; - - /** - * Syntax flag, enables no optional regexp syntax. - */ - public static final int NONE = 0x0000; - - //----- Matching flags ( > 0xff ) ------ - - /** - * Allows case insensitive matching of ASCII characters. - */ - public static final int ASCII_CASE_INSENSITIVE = 0x0100; - - //Immutable parsed state - /** - * The type of expression - */ - public final Kind kind; - /** - * Child expressions held by a container type expression - */ - public final RegExp87 exp1, exp2; - /** - * String expression - */ - public final String s; - /** - * Character expression - */ - public final int c; - /** - * Limits for repeatable type expressions - */ - public final int min, max, digits; - /** - * Extents for range type expressions - */ - public final int from, to; - - // Parser variables - private final String originalString; - final int flags; - int pos; - - /** - * Constructs new RegExp from a string. Same as - * RegExp(s, ALL). - * - * @param s regexp string - * @exception IllegalArgumentException if an error occurred while parsing the - * regular expression - */ - public RegExp87(String s) throws IllegalArgumentException { - this(s, ALL); - } - - /** - * Constructs new RegExp from a string. - * - * @param s regexp string - * @param syntax_flags boolean 'or' of optional syntax constructs to be - * enabled - * @exception IllegalArgumentException if an error occurred while parsing the - * regular expression - */ - public RegExp87(String s, int syntax_flags) throws IllegalArgumentException { - this(s, syntax_flags, 0); - } - /** - * Constructs new RegExp from a string. - * - * @param s regexp string - * @param syntax_flags boolean 'or' of optional syntax constructs to be - * enabled - * @param match_flags boolean 'or' of match behavior options such as case insensitivity - * @exception IllegalArgumentException if an error occurred while parsing the - * regular expression - */ - public RegExp87(String s, int syntax_flags, int match_flags) throws IllegalArgumentException { - if (syntax_flags > ALL) { - throw new IllegalArgumentException("Illegal syntax flag"); - } - - if (match_flags > 0 && match_flags <= ALL) { - throw new IllegalArgumentException("Illegal match flag"); - } - flags = syntax_flags | match_flags; - originalString = s; - RegExp87 e; - if (s.length() == 0) e = makeString(flags, ""); - else { - e = parseUnionExp(); - if (pos < originalString.length()) throw new IllegalArgumentException( - "end-of-string expected at position " + pos); - } - kind = e.kind; - exp1 = e.exp1; - exp2 = e.exp2; - this.s = e.s; - c = e.c; - min = e.min; - max = e.max; - digits = e.digits; - from = e.from; - to = e.to; - } - - RegExp87(int flags, Kind kind, RegExp87 exp1, RegExp87 exp2, String s, int c, int min, int max, int digits, int from, int to){ - this.originalString = null; - this.kind = kind; - this.flags = flags; - this.exp1 = exp1; - this.exp2 = exp2; - this.s = s; - this.c = c; - this.min = min; - this.max = max; - this.digits = digits; - this.from = from; - this.to = to; - } - - // Simplified construction of container nodes - static RegExp87 newContainerNode(int flags, Kind kind, RegExp87 exp1, RegExp87 exp2) { - return new RegExp87(flags, kind, exp1, exp2, null, 0, 0, 0, 0, 0, 0); - } - - // Simplified construction of repeating nodes - static RegExp87 newRepeatingNode(int flags, Kind kind, RegExp87 exp, int min, int max) { - return new RegExp87(flags, kind, exp, null, null, 0, min, max, 0, 0, 0); - } - - - // Simplified construction of leaf nodes - static RegExp87 newLeafNode(int flags, Kind kind, String s, int c, int min, int max, int digits, int from, int to) { - return new RegExp87(flags, kind, null, null, s, c, min, max, digits, from, to); - } - - /** - * Constructs new Automaton from this RegExp. Same - * as toAutomaton(null) (empty automaton map). - */ - public Automaton toAutomaton() { - return toAutomaton(null, null, Operations.DEFAULT_MAX_DETERMINIZED_STATES); - } - - /** - * Constructs new Automaton from this RegExp. The - * constructed automaton is minimal and deterministic and has no transitions - * to dead states. - * - * @param maxDeterminizedStates maximum number of states in the resulting - * automata. If the automata would need more than this many states - * TooComplextToDeterminizeException is thrown. Higher number require more - * space but can process more complex regexes. - * @exception IllegalArgumentException if this regular expression uses a named - * identifier that is not available from the automaton provider - * @exception TooComplexToDeterminizeException if determinizing this regexp - * requires more than maxDeterminizedStates states - */ - public Automaton toAutomaton(int maxDeterminizedStates) - throws IllegalArgumentException, TooComplexToDeterminizeException { - return toAutomaton(null, null, maxDeterminizedStates); - } - - /** - * Constructs new Automaton from this RegExp. The - * constructed automaton is minimal and deterministic and has no transitions - * to dead states. - * - * @param automaton_provider provider of automata for named identifiers - * @param maxDeterminizedStates maximum number of states in the resulting - * automata. If the automata would need more than this many states - * TooComplextToDeterminizeException is thrown. Higher number require more - * space but can process more complex regexes. - * @exception IllegalArgumentException if this regular expression uses a named - * identifier that is not available from the automaton provider - * @exception TooComplexToDeterminizeException if determinizing this regexp - * requires more than maxDeterminizedStates states - */ - public Automaton toAutomaton(AutomatonProvider automaton_provider, - int maxDeterminizedStates) throws IllegalArgumentException, - TooComplexToDeterminizeException { - return toAutomaton(null, automaton_provider, maxDeterminizedStates); - } - - /** - * Constructs new Automaton from this RegExp. The - * constructed automaton is minimal and deterministic and has no transitions - * to dead states. - * - * @param automata a map from automaton identifiers to automata (of type - * Automaton). - * @param maxDeterminizedStates maximum number of states in the resulting - * automata. If the automata would need more than this many states - * TooComplexToDeterminizeException is thrown. Higher number require more - * space but can process more complex regexes. - * @exception IllegalArgumentException if this regular expression uses a named - * identifier that does not occur in the automaton map - * @exception TooComplexToDeterminizeException if determinizing this regexp - * requires more than maxDeterminizedStates states - */ - public Automaton toAutomaton(Map automata, - int maxDeterminizedStates) throws IllegalArgumentException, - TooComplexToDeterminizeException { - return toAutomaton(automata, null, maxDeterminizedStates); - } - - private Automaton toAutomaton(Map automata, - AutomatonProvider automaton_provider, int maxDeterminizedStates) - throws IllegalArgumentException, TooComplexToDeterminizeException { - try { - return toAutomatonInternal(automata, automaton_provider, - maxDeterminizedStates); - } catch (TooComplexToDeterminizeException e) { - // This is a little ugly. Have to pass an instance of core Lucene RegExp just to get error message. - throw new TooComplexToDeterminizeException(new RegExp(this.originalString), e); - } - } - - private Automaton toAutomatonInternal(Map automata, - AutomatonProvider automaton_provider, int maxDeterminizedStates) - throws IllegalArgumentException { - List list; - Automaton a = null; - switch (kind) { - case REGEXP_PRE_CLASS: - RegExp87 expanded = expandPredefined(); - a = expanded.toAutomatonInternal(automata, automaton_provider, maxDeterminizedStates); - break; - case REGEXP_UNION: - list = new ArrayList<>(); - findLeaves(exp1, Kind.REGEXP_UNION, list, automata, automaton_provider, - maxDeterminizedStates); - findLeaves(exp2, Kind.REGEXP_UNION, list, automata, automaton_provider, - maxDeterminizedStates); - a = Operations.union(list); - a = MinimizationOperations.minimize(a, maxDeterminizedStates); - break; - case REGEXP_CONCATENATION: - list = new ArrayList<>(); - findLeaves(exp1, Kind.REGEXP_CONCATENATION, list, automata, - automaton_provider, maxDeterminizedStates); - findLeaves(exp2, Kind.REGEXP_CONCATENATION, list, automata, - automaton_provider, maxDeterminizedStates); - a = Operations.concatenate(list); - a = MinimizationOperations.minimize(a, maxDeterminizedStates); - break; - case REGEXP_INTERSECTION: - a = Operations.intersection( - exp1.toAutomatonInternal( - automata, automaton_provider, maxDeterminizedStates), - exp2.toAutomatonInternal( - automata, automaton_provider, maxDeterminizedStates)); - a = MinimizationOperations.minimize(a, maxDeterminizedStates); - break; - case REGEXP_OPTIONAL: - a = Operations.optional(exp1.toAutomatonInternal(automata, - automaton_provider, maxDeterminizedStates)); - a = MinimizationOperations.minimize(a, maxDeterminizedStates); - break; - case REGEXP_REPEAT: - a = Operations.repeat(exp1.toAutomatonInternal( - automata, automaton_provider, maxDeterminizedStates)); - a = MinimizationOperations.minimize(a, maxDeterminizedStates); - break; - case REGEXP_REPEAT_MIN: - a = exp1.toAutomatonInternal(automata, automaton_provider, maxDeterminizedStates); - int minNumStates = (a.getNumStates() - 1) * min; - if (minNumStates > maxDeterminizedStates) { - throw new TooComplexToDeterminizeException(a, minNumStates); - } - a = Operations.repeat(a, min); - a = MinimizationOperations.minimize(a, maxDeterminizedStates); - break; - case REGEXP_REPEAT_MINMAX: - a = exp1.toAutomatonInternal(automata, automaton_provider, maxDeterminizedStates); - int minMaxNumStates = (a.getNumStates() - 1) * max; - if (minMaxNumStates > maxDeterminizedStates) { - throw new TooComplexToDeterminizeException(a, minMaxNumStates); - } - a = Operations.repeat(a, min, max); - break; - case REGEXP_COMPLEMENT: - a = Operations.complement( - exp1.toAutomatonInternal(automata, automaton_provider, - maxDeterminizedStates), - maxDeterminizedStates); - a = MinimizationOperations.minimize(a, maxDeterminizedStates); - break; - case REGEXP_CHAR: - if (check(ASCII_CASE_INSENSITIVE)) { - a = toCaseInsensitiveChar(c, maxDeterminizedStates); - } else { - a = Automata.makeChar(c); - } - break; - case REGEXP_CHAR_RANGE: - a = Automata.makeCharRange(from, to); - break; - case REGEXP_ANYCHAR: - a = Automata.makeAnyChar(); - break; - case REGEXP_EMPTY: - a = Automata.makeEmpty(); - break; - case REGEXP_STRING: - if (check(ASCII_CASE_INSENSITIVE)) { - a = toCaseInsensitiveString(maxDeterminizedStates); - } else { - a = Automata.makeString(s); - } - break; - case REGEXP_ANYSTRING: - a = Automata.makeAnyString(); - break; - case REGEXP_AUTOMATON: - Automaton aa = null; - if (automata != null) { - aa = automata.get(s); - } - if (aa == null && automaton_provider != null) { - try { - aa = automaton_provider.getAutomaton(s); - } catch (IOException e) { - throw new IllegalArgumentException(e); - } - } - if (aa == null) { - throw new IllegalArgumentException("'" + s + "' not found"); - } - a = aa; - break; - case REGEXP_INTERVAL: - a = Automata.makeDecimalInterval(min, max, digits); - break; - } - return a; - } - private Automaton toCaseInsensitiveChar(int codepoint, int maxDeterminizedStates) { - Automaton case1 = Automata.makeChar(codepoint); - // For now we only work with ASCII characters - if (codepoint > 128) { - return case1; - } - int altCase = Character.isLowerCase(codepoint) ? Character.toUpperCase(codepoint) : Character.toLowerCase(codepoint); - Automaton result; - if (altCase != codepoint) { - result = Operations.union(case1, Automata.makeChar(altCase)); - result = MinimizationOperations.minimize(result, maxDeterminizedStates); - } else { - result = case1; - } - return result; - } - - private Automaton toCaseInsensitiveString(int maxDeterminizedStates) { - List list = new ArrayList<>(); - - Iterator iter = s.codePoints().iterator(); - while (iter.hasNext()) { - list.add(toCaseInsensitiveChar(iter.next(), maxDeterminizedStates)); - } - Automaton a = Operations.concatenate(list); - a = MinimizationOperations.minimize(a, maxDeterminizedStates); - return a; - } - - private void findLeaves(RegExp87 exp, Kind kind, List list, - Map automata, AutomatonProvider automaton_provider, - int maxDeterminizedStates) { - if (exp.kind == kind) { - findLeaves(exp.exp1, kind, list, automata, automaton_provider, - maxDeterminizedStates); - findLeaves(exp.exp2, kind, list, automata, automaton_provider, - maxDeterminizedStates); - } else { - list.add(exp.toAutomatonInternal(automata, automaton_provider, - maxDeterminizedStates)); - } - } - - /** - * The string that was used to construct the regex. Compare to toString. - */ - public String getOriginalString() { - return originalString; - } - - /** - * Constructs string from parsed regular expression. - */ - @Override - public String toString() { - StringBuilder b = new StringBuilder(); - toStringBuilder(b); - return b.toString(); - } - - void toStringBuilder(StringBuilder b) { - switch (kind) { - case REGEXP_UNION: - b.append("("); - exp1.toStringBuilder(b); - b.append("|"); - exp2.toStringBuilder(b); - b.append(")"); - break; - case REGEXP_CONCATENATION: - exp1.toStringBuilder(b); - exp2.toStringBuilder(b); - break; - case REGEXP_INTERSECTION: - b.append("("); - exp1.toStringBuilder(b); - b.append("&"); - exp2.toStringBuilder(b); - b.append(")"); - break; - case REGEXP_OPTIONAL: - b.append("("); - exp1.toStringBuilder(b); - b.append(")?"); - break; - case REGEXP_REPEAT: - b.append("("); - exp1.toStringBuilder(b); - b.append(")*"); - break; - case REGEXP_REPEAT_MIN: - b.append("("); - exp1.toStringBuilder(b); - b.append("){").append(min).append(",}"); - break; - case REGEXP_REPEAT_MINMAX: - b.append("("); - exp1.toStringBuilder(b); - b.append("){").append(min).append(",").append(max).append("}"); - break; - case REGEXP_COMPLEMENT: - b.append("~("); - exp1.toStringBuilder(b); - b.append(")"); - break; - case REGEXP_CHAR: - b.append("\\").appendCodePoint(c); - break; - case REGEXP_CHAR_RANGE: - b.append("[\\").appendCodePoint(from).append("-\\").appendCodePoint(to).append("]"); - break; - case REGEXP_ANYCHAR: - b.append("."); - break; - case REGEXP_EMPTY: - b.append("#"); - break; - case REGEXP_STRING: - b.append("\"").append(s).append("\""); - break; - case REGEXP_ANYSTRING: - b.append("@"); - break; - case REGEXP_AUTOMATON: - b.append("<").append(s).append(">"); - break; - case REGEXP_INTERVAL: - String s1 = Integer.toString(min); - String s2 = Integer.toString(max); - b.append("<"); - if (digits > 0) for (int i = s1.length(); i < digits; i++) - b.append('0'); - b.append(s1).append("-"); - if (digits > 0) for (int i = s2.length(); i < digits; i++) - b.append('0'); - b.append(s2).append(">"); - break; - case REGEXP_PRE_CLASS: - b.append("\\").appendCodePoint(from); - break; - } - } - - /** - * Like to string, but more verbose (shows the higherchy more clearly). - */ - public String toStringTree() { - StringBuilder b = new StringBuilder(); - toStringTree(b, ""); - return b.toString(); - } - - void toStringTree(StringBuilder b, String indent) { - switch (kind) { - // binary - case REGEXP_UNION: - case REGEXP_CONCATENATION: - case REGEXP_INTERSECTION: - b.append(indent); - b.append(kind); - b.append('\n'); - exp1.toStringTree(b, indent + " "); - exp2.toStringTree(b, indent + " "); - break; - // unary - case REGEXP_OPTIONAL: - case REGEXP_REPEAT: - case REGEXP_COMPLEMENT: - b.append(indent); - b.append(kind); - b.append('\n'); - exp1.toStringTree(b, indent + " "); - break; - case REGEXP_REPEAT_MIN: - b.append(indent); - b.append(kind); - b.append(" min="); - b.append(min); - b.append('\n'); - exp1.toStringTree(b, indent + " "); - break; - case REGEXP_REPEAT_MINMAX: - b.append(indent); - b.append(kind); - b.append(" min="); - b.append(min); - b.append(" max="); - b.append(max); - b.append('\n'); - exp1.toStringTree(b, indent + " "); - break; - case REGEXP_CHAR: - b.append(indent); - b.append(kind); - b.append(" char="); - b.appendCodePoint(c); - b.append('\n'); - break; - case REGEXP_PRE_CLASS: - b.append(indent); - b.append(kind); - b.append(" class=\\"); - b.appendCodePoint(from); - b.append('\n'); - break; - case REGEXP_CHAR_RANGE: - b.append(indent); - b.append(kind); - b.append(" from="); - b.appendCodePoint(from); - b.append(" to="); - b.appendCodePoint(to); - b.append('\n'); - break; - case REGEXP_ANYCHAR: - case REGEXP_EMPTY: - b.append(indent); - b.append(kind); - b.append('\n'); - break; - case REGEXP_STRING: - b.append(indent); - b.append(kind); - b.append(" string="); - b.append(s); - b.append('\n'); - break; - case REGEXP_ANYSTRING: - b.append(indent); - b.append(kind); - b.append('\n'); - break; - case REGEXP_AUTOMATON: - b.append(indent); - b.append(kind); - b.append('\n'); - break; - case REGEXP_INTERVAL: - b.append(indent); - b.append(kind); - String s1 = Integer.toString(min); - String s2 = Integer.toString(max); - b.append("<"); - if (digits > 0) for (int i = s1.length(); i < digits; i++) - b.append('0'); - b.append(s1).append("-"); - if (digits > 0) for (int i = s2.length(); i < digits; i++) - b.append('0'); - b.append(s2).append(">"); - b.append('\n'); - break; - } - } - - /** - * Returns set of automaton identifiers that occur in this regular expression. - */ - public Set getIdentifiers() { - HashSet set = new HashSet<>(); - getIdentifiers(set); - return set; - } - - void getIdentifiers(Set 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);