diff --git a/build.gradle b/build.gradle
index d24b3b1f..c365eea1 100644
--- a/build.gradle
+++ b/build.gradle
@@ -220,13 +220,15 @@ asciidoctor {
'source-highlighter': 'coderay'
}
-checkstyleMain.source = 'src/main/java'
+//checkstyleMain.source = 'src/main/java'
// we use @Ignore
-forbiddenApisTest.enabled = false
-forbiddenPatterns.exclude('**/*.txt', '**/*.brk', '**/*.fst', '**/*.tree', '**/*.nrm')
-licenseHeaders.enabled = false
-dependencyLicenses.enabled = false
-thirdPartyAudit.enabled = false
-loggerUsageCheck.enabled = false
-testingConventions.enabled = false
+//forbiddenApisTest.enabled = false
+//tasks.named("forbiddenPatterns").configure {
+// exclude('**/*.txt', '**/*.brk', '**/*.fst', '**/*.tree', '**/*.nrm')
+//}
+//licenseHeaders.enabled = false
+//dependencyLicenses.enabled = false
+//thirdPartyAudit.enabled = false
+//loggerUsageCheck.enabled = false
+//testingConventions.enabled = false
validateNebulaPom.enabled = false
diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml
index 52fe33cc..9217bfcf 100644
--- a/config/checkstyle/checkstyle.xml
+++ b/config/checkstyle/checkstyle.xml
@@ -38,6 +38,22 @@ page at http://checkstyle.sourceforge.net/config.html -->
Only allows a package-info.java, not package.html. -->
+
+
+
+
+
+
+
+
+
+
@@ -73,12 +89,12 @@ page at http://checkstyle.sourceforge.net/config.html -->
-
+
-
-
-
+
+
+
@@ -184,22 +200,6 @@ page at http://checkstyle.sourceforge.net/config.html -->
-->
-
-
-
-
-
-
-
-
-
-
diff --git a/gradle.properties b/gradle.properties
index 80a756fe..8381d578 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,17 +1,16 @@
group = org.xbib.elasticsearch
name = elasticsearch-plugin-bundle
-version = 7.10.1.0
+version = 7.11.1.0
-elasticsearch.version = 7.10.1
+elasticsearch.version = 7.11.1
lucene.version = 8.7.0
icu4j.version = 67.1
standardnumber.version = 1.0.1
-jackson.version = 2.9.10
+jackson.version = 2.10.4
spatial4j.version = 0.7
jts.version = 1.15.1
-jna.version = 4.5.1
-checkstyle.version = 8.13
+jna.version = 5.5.0
wagon.version = 3.0.0
log4j.version = 2.13.1
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index bca17f36..12d38de6 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/src/main/java/org/xbib/elasticsearch/plugin/bundle/BundlePlugin.java b/src/main/java/org/xbib/elasticsearch/plugin/bundle/BundlePlugin.java
index 2320f51b..8970ffcb 100644
--- a/src/main/java/org/xbib/elasticsearch/plugin/bundle/BundlePlugin.java
+++ b/src/main/java/org/xbib/elasticsearch/plugin/bundle/BundlePlugin.java
@@ -31,13 +31,13 @@
import org.xbib.elasticsearch.plugin.bundle.action.isbnformat.TransportISBNFormatAction;
import org.xbib.elasticsearch.plugin.bundle.action.langdetect.LangdetectAction;
import org.xbib.elasticsearch.plugin.bundle.action.langdetect.TransportLangdetectAction;
+import org.xbib.elasticsearch.plugin.bundle.common.standardnumber.StandardnumberService;
import org.xbib.elasticsearch.plugin.bundle.index.analysis.autophrase.AutoPhrasingTokenFilterFactory;
import org.xbib.elasticsearch.plugin.bundle.index.analysis.baseform.BaseformTokenFilterFactory;
import org.xbib.elasticsearch.plugin.bundle.index.analysis.concat.ConcatTokenFilterFactory;
import org.xbib.elasticsearch.plugin.bundle.index.analysis.concat.PairTokenFilterFactory;
-import org.xbib.elasticsearch.plugin.bundle.index.analysis.decompound.patricia.DecompoundTokenFilterFactory;
import org.xbib.elasticsearch.plugin.bundle.index.analysis.decompound.fst.FstDecompoundTokenFilterFactory;
-import org.xbib.elasticsearch.plugin.bundle.index.analysis.lemmatize.LemmatizeTokenFilterFactory;
+import org.xbib.elasticsearch.plugin.bundle.index.analysis.decompound.patricia.DecompoundTokenFilterFactory;
import org.xbib.elasticsearch.plugin.bundle.index.analysis.german.GermanNormalizationFilterFactory;
import org.xbib.elasticsearch.plugin.bundle.index.analysis.hyphen.HyphenAnalyzerProvider;
import org.xbib.elasticsearch.plugin.bundle.index.analysis.hyphen.HyphenTokenFilterFactory;
@@ -51,6 +51,7 @@
import org.xbib.elasticsearch.plugin.bundle.index.analysis.icu.IcuNumberFormatTokenFilterFactory;
import org.xbib.elasticsearch.plugin.bundle.index.analysis.icu.IcuTransformTokenFilterFactory;
import org.xbib.elasticsearch.plugin.bundle.index.analysis.icu.segmentation.IcuTokenizerFactory;
+import org.xbib.elasticsearch.plugin.bundle.index.analysis.lemmatize.LemmatizeTokenFilterFactory;
import org.xbib.elasticsearch.plugin.bundle.index.analysis.naturalsort.NaturalSortKeyAnalyzerProvider;
import org.xbib.elasticsearch.plugin.bundle.index.analysis.naturalsort.NaturalSortKeyTokenizerFactory;
import org.xbib.elasticsearch.plugin.bundle.index.analysis.sortform.SortformAnalyzerProvider;
@@ -65,12 +66,8 @@
import org.xbib.elasticsearch.plugin.bundle.index.mapper.langdetect.LangdetectMapper;
import org.xbib.elasticsearch.plugin.bundle.index.mapper.reference.ReferenceMapper;
import org.xbib.elasticsearch.plugin.bundle.index.mapper.reference.ReferenceMapperModule;
-import org.xbib.elasticsearch.plugin.bundle.index.mapper.reference.ReferenceMapperTypeParser;
-import org.xbib.elasticsearch.plugin.bundle.common.reference.ReferenceService;
import org.xbib.elasticsearch.plugin.bundle.index.mapper.standardnumber.StandardnumberMapper;
import org.xbib.elasticsearch.plugin.bundle.index.mapper.standardnumber.StandardnumberMapperModule;
-import org.xbib.elasticsearch.plugin.bundle.index.mapper.standardnumber.StandardnumberMapperTypeParser;
-import org.xbib.elasticsearch.plugin.bundle.common.standardnumber.StandardnumberService;
import org.xbib.elasticsearch.plugin.bundle.query.decompound.ExactPhraseQueryBuilder;
import org.xbib.elasticsearch.plugin.bundle.rest.action.isbnformat.RestISBNFormatterAction;
import org.xbib.elasticsearch.plugin.bundle.rest.action.langdetect.RestLangdetectAction;
@@ -90,11 +87,9 @@
*/
public class BundlePlugin extends Plugin implements AnalysisPlugin, MapperPlugin, SearchPlugin, ActionPlugin {
- private static final StandardnumberMapperTypeParser standardNumberTypeParser =
- new StandardnumberMapperTypeParser();
+ private final StandardnumberMapper.TypeParser standardNumberTypeParser = StandardnumberMapper.newTypeParser();
- private static final ReferenceMapperTypeParser referenceMapperTypeParser =
- new ReferenceMapperTypeParser();
+ private final ReferenceMapper.TypeParser referenceMapperTypeParser = ReferenceMapper.PARSER;
private final Settings settings;
@@ -244,10 +239,10 @@ public Map getMappers() {
extra.put(ReferenceMapper.CONTENT_TYPE, referenceMapperTypeParser);
}
if (settings.getAsBoolean("plugins.xbib.langdetect.enabled", true)) {
- extra.put(LangdetectMapper.CONTENT_TYPE, new LangdetectMapper.TypeParser());
+ extra.put(LangdetectMapper.CONTENT_TYPE, LangdetectMapper.PARSER);
}
if (settings.getAsBoolean("plugins.xbib.icu.enabled", true)) {
- extra.put(IcuCollationKeyFieldMapper.CONTENT_TYPE, new IcuCollationKeyFieldMapper.TypeParser());
+ extra.put(IcuCollationKeyFieldMapper.CONTENT_TYPE, IcuCollationKeyFieldMapper.PARSER);
}
return extra;
}
@@ -304,9 +299,6 @@ public Collection createGuiceModules() {
@Override
public Collection> getGuiceServiceClasses() {
Collection> extra = new ArrayList<>();
- if (settings.getAsBoolean("plugins.xbib.reference.enabled", true)) {
- extra.add(ReferenceService.class);
- }
if (settings.getAsBoolean("plugins.xbib.standardnumber.enabled", true)) {
extra.add(StandardnumberService.class);
}
diff --git a/src/main/java/org/xbib/elasticsearch/plugin/bundle/action/isbnformat/TransportISBNFormatAction.java b/src/main/java/org/xbib/elasticsearch/plugin/bundle/action/isbnformat/TransportISBNFormatAction.java
index 99a74dc9..03a8d10f 100644
--- a/src/main/java/org/xbib/elasticsearch/plugin/bundle/action/isbnformat/TransportISBNFormatAction.java
+++ b/src/main/java/org/xbib/elasticsearch/plugin/bundle/action/isbnformat/TransportISBNFormatAction.java
@@ -23,7 +23,7 @@ public class TransportISBNFormatAction extends TransportAction DEFAULT_STANDARD_NUMBERS =
Arrays.asList("isbn", "issn", "ismn", "isni", "orcid", "ppn", "zdb");
- /**
- * Called from StandardnumberTokenFilterFactory.
- * @param standardNumberTypeParser the type parser
- */
- public void setStandardNumberTypeParser(StandardnumberMapper.TypeParser standardNumberTypeParser) {
+ @Inject
+ public StandardnumberService(StandardnumberMapper.TypeParser standardNumberTypeParser) {
standardNumberTypeParser.setService(this);
}
diff --git a/src/main/java/org/xbib/elasticsearch/plugin/bundle/index/analysis/standardnumber/StandardnumberTokenFilterFactory.java b/src/main/java/org/xbib/elasticsearch/plugin/bundle/index/analysis/standardnumber/StandardnumberTokenFilterFactory.java
index 42b2cf59..304f3b4f 100644
--- a/src/main/java/org/xbib/elasticsearch/plugin/bundle/index/analysis/standardnumber/StandardnumberTokenFilterFactory.java
+++ b/src/main/java/org/xbib/elasticsearch/plugin/bundle/index/analysis/standardnumber/StandardnumberTokenFilterFactory.java
@@ -5,8 +5,8 @@
import org.elasticsearch.env.Environment;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.analysis.AbstractTokenFilterFactory;
-import org.xbib.elasticsearch.plugin.bundle.index.mapper.standardnumber.StandardnumberMapper;
import org.xbib.elasticsearch.plugin.bundle.common.standardnumber.StandardnumberService;
+import org.xbib.elasticsearch.plugin.bundle.index.mapper.standardnumber.StandardnumberMapper;
/**
* Standard number token filter factory.
@@ -24,8 +24,7 @@ public StandardnumberTokenFilterFactory(IndexSettings indexSettings,
StandardnumberMapper.TypeParser standardNumberTypeParser) {
super(indexSettings, name, settings);
this.settings = settings;
- this.standardnumberService = new StandardnumberService();
- this.standardnumberService.setStandardNumberTypeParser(standardNumberTypeParser);
+ this.standardnumberService = new StandardnumberService(standardNumberTypeParser);
}
@Override
diff --git a/src/main/java/org/xbib/elasticsearch/plugin/bundle/index/mapper/icu/IcuCollationKeyFieldMapper.java b/src/main/java/org/xbib/elasticsearch/plugin/bundle/index/mapper/icu/IcuCollationKeyFieldMapper.java
index f370a103..c206086c 100644
--- a/src/main/java/org/xbib/elasticsearch/plugin/bundle/index/mapper/icu/IcuCollationKeyFieldMapper.java
+++ b/src/main/java/org/xbib/elasticsearch/plugin/bundle/index/mapper/icu/IcuCollationKeyFieldMapper.java
@@ -2,6 +2,8 @@
import com.ibm.icu.text.Collator;
import com.ibm.icu.text.RawCollationKey;
+import com.ibm.icu.text.RuleBasedCollator;
+import com.ibm.icu.util.ULocale;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
import org.apache.lucene.document.SortedSetDocValuesField;
@@ -14,40 +16,33 @@
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.lucene.Lucene;
-import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.Fuzziness;
-import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
-import org.elasticsearch.common.xcontent.support.XContentMapValues;
import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.plain.SortedSetOrdinalsIndexFieldData;
+import org.elasticsearch.index.mapper.ContentPath;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.FieldNamesFieldMapper;
-import org.elasticsearch.index.mapper.KeywordFieldMapper;
import org.elasticsearch.index.mapper.MappedFieldType;
-import org.elasticsearch.index.mapper.Mapper;
-import org.elasticsearch.index.mapper.MapperParsingException;
-import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.mapper.ParseContext;
+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.TypeParsers;
import org.elasticsearch.index.mapper.ValueFetcher;
import org.elasticsearch.index.query.QueryShardContext;
import org.elasticsearch.search.DocValueFormat;
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
import org.elasticsearch.search.lookup.SearchLookup;
-import org.xbib.elasticsearch.plugin.bundle.index.analysis.icu.IcuCollationKeyAnalyzerProvider;
import org.xbib.elasticsearch.plugin.bundle.index.analysis.icu.IndexableBinaryStringTools;
import java.io.IOException;
import java.time.ZoneId;
+import java.util.Arrays;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
-import java.util.function.LongSupplier;
import java.util.function.Supplier;
/**
@@ -57,35 +52,49 @@ public class IcuCollationKeyFieldMapper extends FieldMapper {
public static final String CONTENT_TYPE = "icu_collation_key";
- public static final FieldType FIELD_TYPE = new FieldType();
-
- public static class Defaults {
-
- static {
- FIELD_TYPE.setTokenized(false);
- FIELD_TYPE.setOmitNorms(true);
- FIELD_TYPE.setIndexOptions(IndexOptions.DOCS);
- FIELD_TYPE.freeze();
- }
- }
-
public static final class CollationFieldType extends StringFieldType {
private final Collator collator;
+ private final String nullValue;
+ private final int ignoreAbove;
- public CollationFieldType(String name, boolean isSearchable, boolean hasDocValues, Collator collator, Map meta) {
- super(name, true, false, true, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
- setIndexAnalyzer(Lucene.KEYWORD_ANALYZER);
+ public CollationFieldType(String name, boolean isSearchable, boolean isStored, boolean hasDocValues,
+ Collator collator, String nullValue, int ignoreAbove, Map meta) {
+ super(name, isSearchable, isStored, hasDocValues, TextSearchInfo.SIMPLE_MATCH_ONLY, meta);
this.collator = collator;
+ this.nullValue = nullValue;
+ this.ignoreAbove = ignoreAbove;
+ }
+
+ public CollationFieldType(String name, boolean searchable, Collator collator) {
+ this(name, searchable, false, true, collator, null, Integer.MAX_VALUE, Collections.emptyMap());
}
public CollationFieldType(String name, Collator collator) {
- this(name, true, true, collator, Collections.emptyMap());
+ this(name, true, false, true, collator, null, Integer.MAX_VALUE, Collections.emptyMap());
+ }
+
+ @Override
+ public String typeName() {
+ return CONTENT_TYPE;
}
@Override
- public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) {
- throw new UnsupportedOperationException();
+ public ValueFetcher valueFetcher(QueryShardContext context, String format) {
+ if (format != null) {
+ throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats.");
+ }
+
+ return new SourceValueFetcher(name(), context, nullValue) {
+ @Override
+ protected String parseSourceValue(Object value) {
+ String keywordValue = value.toString();
+ if (keywordValue.length() > ignoreAbove) {
+ return null;
+ }
+ return keywordValue;
+ }
+ };
}
@Override
@@ -110,11 +119,6 @@ public boolean equals(Object o)
return collator != null ? collator.equals(that.collator) : that.collator == null;
}
- @Override
- public String typeName() {
- return CONTENT_TYPE;
- }
-
public Collator collator() {
return collator;
}
@@ -153,24 +157,27 @@ protected BytesRef indexedValueForSearch(Object value) {
@Override
public Query fuzzyQuery(Object value, Fuzziness fuzziness, int prefixLength, int maxExpansions,
boolean transpositions, QueryShardContext context) {
- throw new UnsupportedOperationException();
+ throw new UnsupportedOperationException("[fuzzy] queries are not supported on [" + CONTENT_TYPE + "] fields.");
}
@Override
public Query prefixQuery(String value, MultiTermQuery.RewriteMethod method, boolean caseInsensitive, QueryShardContext context) {
- throw new UnsupportedOperationException();
+ throw new UnsupportedOperationException("[prefix] queries are not supported on [" + CONTENT_TYPE + "] fields.");
}
@Override
public Query regexpQuery(String value, int syntaxFlags, int matchFlags, int maxDeterminizedStates,
MultiTermQuery.RewriteMethod method, QueryShardContext context) {
- throw new UnsupportedOperationException();
+ throw new UnsupportedOperationException("[regexp] queries are not supported on [" + CONTENT_TYPE + "] fields.");
}
+ /*
@Override
- public DocValueFormat docValueFormat(final String format, ZoneId timeZone) {
- return COLLATE_FORMAT;
+ public Query wildcardQuery(
+ String value, MultiTermQuery.RewriteMethod method, boolean caseInsensitive, QueryShardContext context) {
+ throw new UnsupportedOperationException("[wildcard] queries are not supported on [" + CONTENT_TYPE + "] fields.");
}
+ */
public static DocValueFormat COLLATE_FORMAT = new DocValueFormat() {
@Override
@@ -182,16 +189,6 @@ public String getWriteableName() {
public void writeTo(StreamOutput out) {
}
- @Override
- public String format(long value) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public String format(double value) {
- throw new UnsupportedOperationException();
- }
-
@Override
public String format(BytesRef value) {
int encodedLength = IndexableBinaryStringTools.getEncodedLength(value.bytes, value.offset, value.length);
@@ -200,16 +197,6 @@ public String format(BytesRef value) {
return new String(encoded, 0, encodedLength);
}
- @Override
- public long parseLong(String value, boolean roundUp, LongSupplier now) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public double parseDouble(String value, boolean roundUp, LongSupplier now) {
- throw new UnsupportedOperationException();
- }
-
@Override
public BytesRef parseBytesRef(String value) {
char[] encoded = value.toCharArray();
@@ -219,217 +206,260 @@ public BytesRef parseBytesRef(String value) {
return new BytesRef(decoded);
}
};
- }
-
- public static class Builder extends FieldMapper.Builder {
- private Settings.Builder settingsBuilder;
- protected String nullValue;
-
- public Builder(String name) {
- super(name, FIELD_TYPE);
- builder = this;
- this.settingsBuilder = Settings.builder();
- }
@Override
- public Builder indexOptions(IndexOptions indexOptions) {
- if (indexOptions.compareTo(IndexOptions.DOCS_AND_FREQS) > 0) {
- throw new IllegalArgumentException("The [" + CONTENT_TYPE + "] field does not support positions, got [index_options]="
- + indexOptionToString(indexOptions));
- }
- return super.indexOptions(indexOptions);
- }
-
- public String rules() {
- return settingsBuilder.get("rules");
- }
-
- public Builder rules(final String rules) {
- settingsBuilder.put("rules", rules);
- return this;
- }
-
- public String language() {
- return settingsBuilder.get("language");
- }
-
- public Builder language(final String language) {
- settingsBuilder.put("language", language);
- return this;
- }
-
- public String country() {
- return settingsBuilder.get("country");
- }
-
- public Builder country(final String country) {
- settingsBuilder.put("country", country);
- return this;
+ public DocValueFormat docValueFormat(final String format, final ZoneId timeZone) {
+ return COLLATE_FORMAT;
}
- public String variant() {
- return settingsBuilder.get("variant");
- }
+ }
- public Builder variant(final String variant) {
- settingsBuilder.put("variant", variant);
- return this;
- }
+ private static IcuCollationKeyFieldMapper toType(FieldMapper in) {
+ return (IcuCollationKeyFieldMapper) in;
+ }
+
+ public static class Builder extends FieldMapper.Builder {
+
+ final Parameter indexed = Parameter.indexParam(m -> toType(m).indexed, true);
+ final Parameter hasDocValues = Parameter.docValuesParam(m -> toType(m).hasDocValues, true);
+ final Parameter stored = Parameter.storeParam(m -> toType(m).fieldType.stored(), false);
+
+ final Parameter indexOptions
+ = Parameter.restrictedStringParam("index_options", false, m -> toType(m).indexOptions, "docs", "freqs");
+ final Parameter hasNorms = TextParams.norms(false, m -> !toType(m).fieldType.omitNorms());
+
+ final Parameter