From 95b6822f46d759586565a25216df2c8d49bc39a0 Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Thu, 3 Jul 2014 13:13:14 +0200 Subject: [PATCH] [TEST] Exclude SORANI analyzer if compatibility version is < 1.3.0 --- .../BasicAnalysisBackwardCompatibilityTests.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/elasticsearch/bwcompat/BasicAnalysisBackwardCompatibilityTests.java b/src/test/java/org/elasticsearch/bwcompat/BasicAnalysisBackwardCompatibilityTests.java index 8e9ecd8fef8..5da54ff1e3d 100644 --- a/src/test/java/org/elasticsearch/bwcompat/BasicAnalysisBackwardCompatibilityTests.java +++ b/src/test/java/org/elasticsearch/bwcompat/BasicAnalysisBackwardCompatibilityTests.java @@ -19,6 +19,7 @@ package org.elasticsearch.bwcompat; import com.carrotsearch.randomizedtesting.generators.RandomPicks; +import org.elasticsearch.Version; import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse; import org.elasticsearch.indices.analysis.PreBuiltAnalyzers; import org.elasticsearch.test.ElasticsearchBackwardsCompatIntegrationTest; @@ -50,7 +51,7 @@ public class BasicAnalysisBackwardCompatibilityTests extends ElasticsearchBackwa int fieldId = 0; for (int i = 0; i < fields.length; i++) { fields[i++] = "field_" + fieldId++; - String analyzer = RandomPicks.randomFrom(getRandom(), PreBuiltAnalyzers.values()).name().toLowerCase(Locale.ROOT); + String analyzer = randomAnalyzer(); fields[i] = "type=string,analyzer=" + analyzer; } assertAcked(prepareCreate("test") @@ -89,6 +90,17 @@ public class BasicAnalysisBackwardCompatibilityTests extends ElasticsearchBackwa } } + private String randomAnalyzer() { + while(true) { + PreBuiltAnalyzers preBuiltAnalyzers = RandomPicks.randomFrom(getRandom(), PreBuiltAnalyzers.values()); + if (preBuiltAnalyzers == PreBuiltAnalyzers.SORANI && compatibilityVersion().before(Version.V_1_3_0)) { + continue; // SORANI was added in 1.3.0 + } + return preBuiltAnalyzers.name().toLowerCase(Locale.ROOT); + } + + } + private static final class InputOutput { final AnalyzeResponse response; final String input;