diff --git a/src/main/java/org/elasticsearch/common/lucene/Lucene.java b/src/main/java/org/elasticsearch/common/lucene/Lucene.java index 524f0a00bb4..3a940db19d9 100644 --- a/src/main/java/org/elasticsearch/common/lucene/Lucene.java +++ b/src/main/java/org/elasticsearch/common/lucene/Lucene.java @@ -44,8 +44,6 @@ import org.elasticsearch.index.fielddata.IndexFieldData; import java.io.IOException; import java.util.Locale; -import static org.elasticsearch.common.lucene.search.NoopCollector.NOOP_COLLECTOR; - /** * */ @@ -556,7 +554,7 @@ public class Lucene { } catch (IllegalArgumentException e) { final String parsedMatchVersion = toParse .toUpperCase(Locale.ROOT) - .replaceFirst("^(\\d+)\\.(\\d+).(\\d+)$", "LUCENE_$1_$2"); + .replaceFirst("^(\\d+)\\.(\\d+)(.(\\d+))+$", "LUCENE_$1_$2"); return Version.valueOf(parsedMatchVersion); } } diff --git a/src/test/java/org/elasticsearch/VersionTests.java b/src/test/java/org/elasticsearch/VersionTests.java index c84ec986ed1..9c223a25d94 100644 --- a/src/test/java/org/elasticsearch/VersionTests.java +++ b/src/test/java/org/elasticsearch/VersionTests.java @@ -128,9 +128,12 @@ public class VersionTests extends ElasticsearchTestCase { .replaceFirst("^LUCENE_(\\d+)_(\\d+)$", "$1.$2"); if (randomBoolean()) { string = string + "." + randomIntBetween(0, 100); + if (randomBoolean()) { + string = string + "." + randomIntBetween(0, 100); + } } assertThat(luceneVersion, Matchers.equalTo(Lucene.parseVersionLenient(string, null))); } } -} \ No newline at end of file +}