Skip to content

Commit

Permalink
Fix split package in analysis-icu plugin (#78037)
Browse files Browse the repository at this point in the history
The analysis-icu plugin reuses server package names for analysis and
mappers. This commit moves the plugin implementation to use a single
package name, o.e.p.analysis.icu
  • Loading branch information
rjernst authored Sep 21, 2021
1 parent 8f2a9b9 commit a725d28
Show file tree
Hide file tree
Showing 25 changed files with 75 additions and 47 deletions.
14 changes: 0 additions & 14 deletions plugins/analysis-icu/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,3 @@ tasks.named("yamlRestTestV7CompatTest").configure {
'analysis_icu/10_basic/Normalization with deprecated unicodeSetFilter' // Cleanup versioned deprecations in analysis #41560
].join(',')
}

tasks.named('splitPackagesAudit').configure {
// o.e.i.analysis is owned by server. Move these to an icu package
ignoreClasses 'org.elasticsearch.index.analysis.ICUCollationKeyFilter',
'org.elasticsearch.index.analysis.IcuAnalyzerProvider',
'org.elasticsearch.index.analysis.IcuCollationTokenFilterFactory',
'org.elasticsearch.index.analysis.IcuFoldingTokenFilterFactory',
'org.elasticsearch.index.analysis.IcuNormalizerCharFilterFactory',
'org.elasticsearch.index.analysis.IcuNormalizerTokenFilterFactory',
'org.elasticsearch.index.analysis.IcuTokenizerFactory',
'org.elasticsearch.index.analysis.IcuTransformTokenFilterFactory',
'org.elasticsearch.index.analysis.IndexableBinaryStringTools',
'org.elasticsearch.index.mapper.ICUCollationKeywordFieldMapper'
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,8 @@
import org.elasticsearch.common.io.stream.NamedWriteableRegistry;
import org.elasticsearch.index.analysis.AnalyzerProvider;
import org.elasticsearch.index.analysis.CharFilterFactory;
import org.elasticsearch.index.analysis.IcuAnalyzerProvider;
import org.elasticsearch.index.analysis.IcuCollationTokenFilterFactory;
import org.elasticsearch.index.analysis.IcuFoldingTokenFilterFactory;
import org.elasticsearch.index.analysis.IcuNormalizerCharFilterFactory;
import org.elasticsearch.index.analysis.IcuNormalizerTokenFilterFactory;
import org.elasticsearch.index.analysis.IcuTokenizerFactory;
import org.elasticsearch.index.analysis.IcuTransformTokenFilterFactory;
import org.elasticsearch.index.analysis.TokenFilterFactory;
import org.elasticsearch.index.analysis.TokenizerFactory;
import org.elasticsearch.index.mapper.ICUCollationKeywordFieldMapper;
import org.elasticsearch.index.mapper.Mapper;
import org.elasticsearch.indices.analysis.AnalysisModule.AnalysisProvider;
import org.elasticsearch.plugins.AnalysisPlugin;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.elasticsearch.index.analysis;
package org.elasticsearch.plugin.analysis.icu;

/* @notice
* Licensed to the Apache Software Foundation (ASF) under one or more
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

package org.elasticsearch.index.mapper;
package org.elasticsearch.plugin.analysis.icu;

import com.ibm.icu.text.Collator;
import com.ibm.icu.text.RawCollationKey;
Expand All @@ -25,7 +25,15 @@
import org.elasticsearch.common.unit.Fuzziness;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.index.analysis.IndexableBinaryStringTools;
import org.elasticsearch.index.mapper.DocumentParserContext;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.MappedFieldType;
import org.elasticsearch.index.mapper.MapperBuilderContext;
import org.elasticsearch.index.mapper.SourceValueFetcher;
import org.elasticsearch.index.mapper.StringFieldType;
import org.elasticsearch.index.mapper.TextParams;
import org.elasticsearch.index.mapper.TextSearchInfo;
import org.elasticsearch.index.mapper.ValueFetcher;
import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.plain.SortedSetOrdinalsIndexFieldData;
import org.elasticsearch.index.query.SearchExecutionContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

package org.elasticsearch.index.analysis;
package org.elasticsearch.plugin.analysis.icu;

import com.ibm.icu.text.Normalizer2;
import org.apache.lucene.analysis.Analyzer;
Expand All @@ -17,6 +17,7 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.analysis.AbstractIndexAnalyzerProvider;

import java.io.Reader;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

package org.elasticsearch.index.analysis;
package org.elasticsearch.plugin.analysis.icu;

import java.io.IOException;
import java.nio.charset.Charset;
Expand All @@ -22,6 +22,7 @@
import com.ibm.icu.text.Collator;
import com.ibm.icu.text.RuleBasedCollator;
import com.ibm.icu.util.ULocale;
import org.elasticsearch.index.analysis.AbstractTokenFilterFactory;

/**
* An ICU based collation token filter. There are two ways to configure collation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

package org.elasticsearch.index.analysis;
package org.elasticsearch.plugin.analysis.icu;

import com.ibm.icu.text.Normalizer2;

Expand All @@ -15,6 +15,8 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.analysis.AbstractTokenFilterFactory;
import org.elasticsearch.index.analysis.NormalizingTokenFilterFactory;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

package org.elasticsearch.index.analysis;
package org.elasticsearch.plugin.analysis.icu;


import com.ibm.icu.text.Normalizer2;
Expand All @@ -15,6 +15,8 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.analysis.AbstractCharFilterFactory;
import org.elasticsearch.index.analysis.NormalizingCharFilterFactory;

import java.io.Reader;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

package org.elasticsearch.index.analysis;
package org.elasticsearch.plugin.analysis.icu;

import com.ibm.icu.text.FilteredNormalizer2;
import com.ibm.icu.text.Normalizer2;
Expand All @@ -15,6 +15,8 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.analysis.AbstractTokenFilterFactory;
import org.elasticsearch.index.analysis.NormalizingTokenFilterFactory;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

package org.elasticsearch.index.analysis;
package org.elasticsearch.plugin.analysis.icu;

import com.ibm.icu.lang.UCharacter;
import com.ibm.icu.lang.UProperty;
Expand All @@ -21,6 +21,7 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.analysis.AbstractTokenizerFactory;

import java.io.IOException;
import java.nio.file.Files;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
* Side Public License, v 1.
*/

package org.elasticsearch.index.analysis;
package org.elasticsearch.plugin.analysis.icu;

import com.ibm.icu.text.Transliterator;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.icu.ICUTransformFilter;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.analysis.AbstractTokenFilterFactory;
import org.elasticsearch.index.analysis.NormalizingTokenFilterFactory;

public class IcuTransformTokenFilterFactory extends AbstractTokenFilterFactory implements NormalizingTokenFilterFactory {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.elasticsearch.index.analysis;
package org.elasticsearch.plugin.analysis.icu;

/* @notice
* Licensed to the Apache Software Foundation (ASF) under one or more
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
* Side Public License, v 1.
*/

package org.elasticsearch.index.analysis;
package org.elasticsearch.plugin.analysis.icu;

import org.elasticsearch.plugin.analysis.icu.IcuFoldingTokenFilterFactory;
import org.elasticsearch.plugin.analysis.icu.IcuNormalizerCharFilterFactory;
import org.elasticsearch.plugin.analysis.icu.IcuNormalizerTokenFilterFactory;
import org.elasticsearch.plugin.analysis.icu.IcuTokenizerFactory;
import org.elasticsearch.plugin.analysis.icu.IcuTransformTokenFilterFactory;
import org.elasticsearch.indices.analysis.AnalysisFactoryTestCase;
import org.elasticsearch.plugin.analysis.icu.AnalysisICUPlugin;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
package org.elasticsearch.index.mapper;
package org.elasticsearch.plugin.analysis.icu;

import com.carrotsearch.randomizedtesting.generators.RandomStrings;
import com.ibm.icu.text.Collator;
Expand All @@ -18,15 +18,17 @@
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.common.unit.Fuzziness;
import org.elasticsearch.index.mapper.ICUCollationKeywordFieldMapper.CollationFieldType;
import org.elasticsearch.index.mapper.FieldTypeTestCase;
import org.elasticsearch.index.mapper.MappedFieldType;
import org.elasticsearch.plugin.analysis.icu.ICUCollationKeywordFieldMapper.CollationFieldType;
import org.elasticsearch.index.mapper.MappedFieldType.Relation;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class CollationFieldTypeTests extends FieldTypeTestCase{
public class CollationFieldTypeTests extends FieldTypeTestCase {

private static final Collator DEFAULT_COLLATOR = Collator.getInstance(ULocale.ROOT).freeze();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
package org.elasticsearch.index.mapper;
package org.elasticsearch.plugin.analysis.icu;

import com.ibm.icu.text.Collator;
import com.ibm.icu.text.RawCollationKey;
Expand All @@ -21,6 +21,13 @@
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.mapper.DocumentMapper;
import org.elasticsearch.index.mapper.MappedFieldType;
import org.elasticsearch.index.mapper.MapperParsingException;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.mapper.MapperTestCase;
import org.elasticsearch.index.mapper.ParsedDocument;
import org.elasticsearch.index.mapper.SourceToParse;
import org.elasticsearch.plugin.analysis.icu.AnalysisICUPlugin;
import org.elasticsearch.plugins.Plugin;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
* Side Public License, v 1.
*/

package org.elasticsearch.index.mapper;
package org.elasticsearch.plugin.analysis.icu;

import org.elasticsearch.index.mapper.FieldTypeTestCase;
import org.elasticsearch.index.mapper.MapperBuilderContext;
import org.elasticsearch.plugin.analysis.icu.ICUCollationKeywordFieldMapper;

import java.io.IOException;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
* Side Public License, v 1.
*/

package org.elasticsearch.index.analysis;
package org.elasticsearch.plugin.analysis.icu;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.BaseTokenStreamTestCase;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.plugin.analysis.icu.IcuAnalyzerProvider;
import org.elasticsearch.plugin.analysis.icu.AnalysisICUPlugin;
import org.elasticsearch.test.IndexSettingsModule;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
* Side Public License, v 1.
*/

package org.elasticsearch.index.analysis;
package org.elasticsearch.plugin.analysis.icu;

import org.apache.lucene.analysis.icu.segmentation.ICUTokenizer;
import org.elasticsearch.Version;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.env.Environment;
import org.elasticsearch.index.Index;
import org.elasticsearch.plugin.analysis.icu.AnalysisICUPlugin;
import org.elasticsearch.index.analysis.TokenizerFactory;
import org.elasticsearch.test.ESTestCase;

import java.io.IOException;
Expand Down Expand Up @@ -81,7 +81,7 @@ private static TestAnalysis createTestAnalysis() throws IOException {
Files.copy(keywords, config.resolve("KeywordTokenizer.rbbi"));
Files.copy(latin, config.resolve("Latin-dont-break-on-hyphens.rbbi"));

String json = "/org/elasticsearch/index/analysis/icu_analysis.json";
String json = "/org/elasticsearch/plugin/analysis/icu/icu_analysis.json";

Settings settings = Settings.builder()
.loadFromStream(json, IcuTokenizerFactoryTests.class.getResourceAsStream(json), false)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.elasticsearch.index.analysis;
package org.elasticsearch.plugin.analysis.icu;

/* @notice
* Licensed to the Apache Software Foundation (ASF) under one or more
Expand All @@ -24,6 +24,7 @@
import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TimeUnits;
import org.elasticsearch.plugin.analysis.icu.IndexableBinaryStringTools;
import org.elasticsearch.test.junit.listeners.ReproduceInfoPrinter;
import org.junit.BeforeClass;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,19 @@
* Side Public License, v 1.
*/

package org.elasticsearch.index.analysis;
package org.elasticsearch.plugin.analysis.icu;

import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.analysis.CharFilterFactory;
import org.elasticsearch.index.analysis.TokenFilterFactory;
import org.elasticsearch.index.analysis.TokenizerFactory;
import org.elasticsearch.plugin.analysis.icu.IcuCollationTokenFilterFactory;
import org.elasticsearch.plugin.analysis.icu.IcuFoldingTokenFilterFactory;
import org.elasticsearch.plugin.analysis.icu.IcuNormalizerCharFilterFactory;
import org.elasticsearch.plugin.analysis.icu.IcuNormalizerTokenFilterFactory;
import org.elasticsearch.plugin.analysis.icu.IcuTokenizerFactory;
import org.elasticsearch.plugin.analysis.icu.IcuTransformTokenFilterFactory;
import org.elasticsearch.plugin.analysis.icu.AnalysisICUPlugin;
import org.elasticsearch.test.ESTestCase;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

package org.elasticsearch.index.analysis;
package org.elasticsearch.plugin.analysis.icu;

import com.ibm.icu.text.Collator;
import com.ibm.icu.text.RuleBasedCollator;
Expand All @@ -17,6 +17,7 @@
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.analysis.TokenFilterFactory;
import org.elasticsearch.plugin.analysis.icu.AnalysisICUPlugin;
import org.elasticsearch.test.ESTestCase;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
* Side Public License, v 1.
*/

package org.elasticsearch.index.analysis;
package org.elasticsearch.plugin.analysis.icu;

import com.ibm.icu.text.Normalizer2;
import org.apache.lucene.analysis.CharFilter;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.analysis.CharFilterFactory;
import org.elasticsearch.plugin.analysis.icu.AnalysisICUPlugin;
import org.elasticsearch.test.ESTestCase;

Expand Down

0 comments on commit a725d28

Please sign in to comment.