diff --git a/core/src/main/java/org/elasticsearch/index/analysis/Analysis.java b/core/src/main/java/org/elasticsearch/index/analysis/Analysis.java
index 1054721535e..2ce5e489027 100644
--- a/core/src/main/java/org/elasticsearch/index/analysis/Analysis.java
+++ b/core/src/main/java/org/elasticsearch/index/analysis/Analysis.java
@@ -305,33 +305,4 @@ public class Analysis {
}
}
- /**
- * Check whether the provided token stream is able to provide character
- * terms.
- *
Although most analyzers generate character terms (CharTermAttribute),
- * some token only contain binary terms (BinaryTermAttribute,
- * CharTermAttribute being a special type of BinaryTermAttribute), such as
- * {@link LegacyNumericTokenStream} and unsuitable for highlighting and
- * more-like-this queries which expect character terms.
- */
- public static boolean isCharacterTokenStream(TokenStream tokenStream) {
- try {
- tokenStream.addAttribute(CharTermAttribute.class);
- return true;
- } catch (IllegalArgumentException e) {
- return false;
- }
- }
-
- /**
- * Check whether {@link TokenStream}s generated with analyzer
- * provide with character terms.
- * @see #isCharacterTokenStream(TokenStream)
- */
- public static boolean generatesCharacterTokenStream(Analyzer analyzer, String fieldName) throws IOException {
- try (TokenStream ts = analyzer.tokenStream(fieldName, "")) {
- return isCharacterTokenStream(ts);
- }
- }
-
}
diff --git a/core/src/main/java/org/elasticsearch/index/analysis/NumericAnalyzer.java b/core/src/main/java/org/elasticsearch/index/analysis/NumericAnalyzer.java
deleted file mode 100644
index 251ef53ce15..00000000000
--- a/core/src/main/java/org/elasticsearch/index/analysis/NumericAnalyzer.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch 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.elasticsearch.index.analysis;
-
-import org.apache.lucene.analysis.Analyzer;
-
-import java.io.IOException;
-
-/**
- *
- */
-public abstract class NumericAnalyzer extends Analyzer {
-
- @Override
- protected TokenStreamComponents createComponents(String fieldName) {
- try {
- // LUCENE 4 UPGRADE: in reusableTokenStream the buffer size was char[120]
- // Not sure if this is intentional or not
- return new TokenStreamComponents(createNumericTokenizer(new char[32]));
- } catch (IOException e) {
- throw new RuntimeException("Failed to create numeric tokenizer", e);
- }
- }
-
- protected abstract T createNumericTokenizer(char[] buffer) throws IOException;
-}
diff --git a/core/src/main/java/org/elasticsearch/index/analysis/NumericDateAnalyzer.java b/core/src/main/java/org/elasticsearch/index/analysis/NumericDateAnalyzer.java
deleted file mode 100644
index f4873e04437..00000000000
--- a/core/src/main/java/org/elasticsearch/index/analysis/NumericDateAnalyzer.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch 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.elasticsearch.index.analysis;
-
-import com.carrotsearch.hppc.IntObjectHashMap;
-import org.elasticsearch.common.joda.FormatDateTimeFormatter;
-import org.joda.time.format.DateTimeFormatter;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- *
- */
-public class NumericDateAnalyzer extends NumericAnalyzer {
-
- private static final Map> globalAnalyzers = new HashMap<>();
-
- public static synchronized NamedAnalyzer buildNamedAnalyzer(FormatDateTimeFormatter formatter, int precisionStep) {
- IntObjectHashMap precisionMap = globalAnalyzers.get(formatter.format());
- if (precisionMap == null) {
- precisionMap = new IntObjectHashMap<>();
- globalAnalyzers.put(formatter.format(), precisionMap);
- }
- NamedAnalyzer namedAnalyzer = precisionMap.get(precisionStep);
- if (namedAnalyzer == null) {
- String name = "_date/" + ((precisionStep == Integer.MAX_VALUE) ? "max" : precisionStep);
- namedAnalyzer = new NamedAnalyzer(name, AnalyzerScope.GLOBAL, new NumericDateAnalyzer(precisionStep, formatter.parser()));
- precisionMap.put(precisionStep, namedAnalyzer);
- }
- return namedAnalyzer;
- }
-
- private final int precisionStep;
- private final DateTimeFormatter dateTimeFormatter;
-
- public NumericDateAnalyzer(int precisionStep, DateTimeFormatter dateTimeFormatter) {
- this.precisionStep = precisionStep;
- this.dateTimeFormatter = dateTimeFormatter;
- }
-
- @Override
- protected NumericDateTokenizer createNumericTokenizer(char[] buffer) throws IOException {
- return new NumericDateTokenizer(precisionStep, buffer, dateTimeFormatter);
- }
-}
\ No newline at end of file
diff --git a/core/src/main/java/org/elasticsearch/index/analysis/NumericDateTokenizer.java b/core/src/main/java/org/elasticsearch/index/analysis/NumericDateTokenizer.java
deleted file mode 100644
index 21a13eab573..00000000000
--- a/core/src/main/java/org/elasticsearch/index/analysis/NumericDateTokenizer.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch 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.elasticsearch.index.analysis;
-
-import org.apache.lucene.analysis.LegacyNumericTokenStream;
-import org.joda.time.format.DateTimeFormatter;
-
-import java.io.IOException;
-
-/**
- *
- */
-public class NumericDateTokenizer extends NumericTokenizer {
-
- public NumericDateTokenizer(int precisionStep, char[] buffer, DateTimeFormatter dateTimeFormatter) throws IOException {
- super(new LegacyNumericTokenStream(precisionStep), buffer, dateTimeFormatter);
- }
-
- @Override
- protected void setValue(LegacyNumericTokenStream tokenStream, String value) {
- tokenStream.setLongValue(((DateTimeFormatter) extra).parseMillis(value));
- }
-}
\ No newline at end of file
diff --git a/core/src/main/java/org/elasticsearch/index/analysis/NumericDoubleAnalyzer.java b/core/src/main/java/org/elasticsearch/index/analysis/NumericDoubleAnalyzer.java
deleted file mode 100644
index 77716e7a43d..00000000000
--- a/core/src/main/java/org/elasticsearch/index/analysis/NumericDoubleAnalyzer.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch 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.elasticsearch.index.analysis;
-
-import com.carrotsearch.hppc.IntObjectHashMap;
-
-import java.io.IOException;
-
-/**
- *
- */
-public class NumericDoubleAnalyzer extends NumericAnalyzer {
-
- private final static IntObjectHashMap builtIn;
-
- static {
- builtIn = new IntObjectHashMap<>();
- builtIn.put(Integer.MAX_VALUE, new NamedAnalyzer("_double/max", AnalyzerScope.GLOBAL, new NumericDoubleAnalyzer(Integer.MAX_VALUE)));
- for (int i = 0; i <= 64; i += 4) {
- builtIn.put(i, new NamedAnalyzer("_double/" + i, AnalyzerScope.GLOBAL, new NumericDoubleAnalyzer(i)));
- }
- }
-
- public static NamedAnalyzer buildNamedAnalyzer(int precisionStep) {
- NamedAnalyzer namedAnalyzer = builtIn.get(precisionStep);
- if (namedAnalyzer == null) {
- namedAnalyzer = new NamedAnalyzer("_double/" + precisionStep, AnalyzerScope.INDEX, new NumericDoubleAnalyzer(precisionStep));
- }
- return namedAnalyzer;
- }
-
- private final int precisionStep;
-
- public NumericDoubleAnalyzer(int precisionStep) {
- this.precisionStep = precisionStep;
- }
-
- @Override
- protected NumericDoubleTokenizer createNumericTokenizer(char[] buffer) throws IOException {
- return new NumericDoubleTokenizer(precisionStep, buffer);
- }
-}
diff --git a/core/src/main/java/org/elasticsearch/index/analysis/NumericDoubleTokenizer.java b/core/src/main/java/org/elasticsearch/index/analysis/NumericDoubleTokenizer.java
deleted file mode 100644
index 6be6199b529..00000000000
--- a/core/src/main/java/org/elasticsearch/index/analysis/NumericDoubleTokenizer.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch 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.elasticsearch.index.analysis;
-
-import org.apache.lucene.analysis.LegacyNumericTokenStream;
-
-import java.io.IOException;
-
-/**
- *
- */
-public class NumericDoubleTokenizer extends NumericTokenizer {
-
- public NumericDoubleTokenizer(int precisionStep, char[] buffer) throws IOException {
- super(new LegacyNumericTokenStream(precisionStep), buffer, null);
- }
-
- @Override
- protected void setValue(LegacyNumericTokenStream tokenStream, String value) {
- tokenStream.setDoubleValue(Double.parseDouble(value));
- }
-}
\ No newline at end of file
diff --git a/core/src/main/java/org/elasticsearch/index/analysis/NumericFloatAnalyzer.java b/core/src/main/java/org/elasticsearch/index/analysis/NumericFloatAnalyzer.java
deleted file mode 100644
index e8ee0295cff..00000000000
--- a/core/src/main/java/org/elasticsearch/index/analysis/NumericFloatAnalyzer.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch 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.elasticsearch.index.analysis;
-
-import com.carrotsearch.hppc.IntObjectHashMap;
-
-import java.io.IOException;
-
-/**
- *
- */
-public class NumericFloatAnalyzer extends NumericAnalyzer {
-
- private final static IntObjectHashMap builtIn;
-
- static {
- builtIn = new IntObjectHashMap<>();
- builtIn.put(Integer.MAX_VALUE, new NamedAnalyzer("_float/max", AnalyzerScope.GLOBAL, new NumericFloatAnalyzer(Integer.MAX_VALUE)));
- for (int i = 0; i <= 64; i += 4) {
- builtIn.put(i, new NamedAnalyzer("_float/" + i, AnalyzerScope.GLOBAL, new NumericFloatAnalyzer(i)));
- }
- }
-
- public static NamedAnalyzer buildNamedAnalyzer(int precisionStep) {
- NamedAnalyzer namedAnalyzer = builtIn.get(precisionStep);
- if (namedAnalyzer == null) {
- namedAnalyzer = new NamedAnalyzer("_float/" + precisionStep, AnalyzerScope.INDEX, new NumericFloatAnalyzer(precisionStep));
- }
- return namedAnalyzer;
- }
-
- private final int precisionStep;
-
- public NumericFloatAnalyzer(int precisionStep) {
- this.precisionStep = precisionStep;
- }
-
- @Override
- protected NumericFloatTokenizer createNumericTokenizer(char[] buffer) throws IOException {
- return new NumericFloatTokenizer(precisionStep, buffer);
- }
-}
diff --git a/core/src/main/java/org/elasticsearch/index/analysis/NumericFloatTokenizer.java b/core/src/main/java/org/elasticsearch/index/analysis/NumericFloatTokenizer.java
deleted file mode 100644
index b7b2f6577f9..00000000000
--- a/core/src/main/java/org/elasticsearch/index/analysis/NumericFloatTokenizer.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch 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.elasticsearch.index.analysis;
-
-import org.apache.lucene.analysis.LegacyNumericTokenStream;
-
-import java.io.IOException;
-
-/**
- *
- */
-public class NumericFloatTokenizer extends NumericTokenizer {
-
- public NumericFloatTokenizer(int precisionStep, char[] buffer) throws IOException {
- super(new LegacyNumericTokenStream(precisionStep), buffer, null);
- }
-
- @Override
- protected void setValue(LegacyNumericTokenStream tokenStream, String value) {
- tokenStream.setFloatValue(Float.parseFloat(value));
- }
-}
\ No newline at end of file
diff --git a/core/src/main/java/org/elasticsearch/index/analysis/NumericIntegerAnalyzer.java b/core/src/main/java/org/elasticsearch/index/analysis/NumericIntegerAnalyzer.java
deleted file mode 100644
index 87cbca6f594..00000000000
--- a/core/src/main/java/org/elasticsearch/index/analysis/NumericIntegerAnalyzer.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch 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.elasticsearch.index.analysis;
-
-import com.carrotsearch.hppc.IntObjectHashMap;
-
-import java.io.IOException;
-
-/**
- *
- */
-public class NumericIntegerAnalyzer extends NumericAnalyzer {
-
- private final static IntObjectHashMap builtIn;
-
- static {
- builtIn = new IntObjectHashMap<>();
- builtIn.put(Integer.MAX_VALUE, new NamedAnalyzer("_int/max", AnalyzerScope.GLOBAL, new NumericIntegerAnalyzer(Integer.MAX_VALUE)));
- for (int i = 0; i <= 64; i += 4) {
- builtIn.put(i, new NamedAnalyzer("_int/" + i, AnalyzerScope.GLOBAL, new NumericIntegerAnalyzer(i)));
- }
- }
-
- public static NamedAnalyzer buildNamedAnalyzer(int precisionStep) {
- NamedAnalyzer namedAnalyzer = builtIn.get(precisionStep);
- if (namedAnalyzer == null) {
- namedAnalyzer = new NamedAnalyzer("_int/" + precisionStep, AnalyzerScope.INDEX, new NumericIntegerAnalyzer(precisionStep));
- }
- return namedAnalyzer;
- }
-
- private final int precisionStep;
-
- public NumericIntegerAnalyzer(int precisionStep) {
- this.precisionStep = precisionStep;
- }
-
- @Override
- protected NumericIntegerTokenizer createNumericTokenizer(char[] buffer) throws IOException {
- return new NumericIntegerTokenizer(precisionStep, buffer);
- }
-}
diff --git a/core/src/main/java/org/elasticsearch/index/analysis/NumericIntegerTokenizer.java b/core/src/main/java/org/elasticsearch/index/analysis/NumericIntegerTokenizer.java
deleted file mode 100644
index 3d8b1309997..00000000000
--- a/core/src/main/java/org/elasticsearch/index/analysis/NumericIntegerTokenizer.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch 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.elasticsearch.index.analysis;
-
-import org.apache.lucene.analysis.LegacyNumericTokenStream;
-
-import java.io.IOException;
-
-/**
- *
- */
-public class NumericIntegerTokenizer extends NumericTokenizer {
-
- public NumericIntegerTokenizer(int precisionStep, char[] buffer) throws IOException {
- super(new LegacyNumericTokenStream(precisionStep), buffer, null);
- }
-
- @Override
- protected void setValue(LegacyNumericTokenStream tokenStream, String value) {
- tokenStream.setIntValue(Integer.parseInt(value));
- }
-}
diff --git a/core/src/main/java/org/elasticsearch/index/analysis/NumericLongAnalyzer.java b/core/src/main/java/org/elasticsearch/index/analysis/NumericLongAnalyzer.java
deleted file mode 100644
index 9b865920341..00000000000
--- a/core/src/main/java/org/elasticsearch/index/analysis/NumericLongAnalyzer.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch 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.elasticsearch.index.analysis;
-
-import com.carrotsearch.hppc.IntObjectHashMap;
-
-import java.io.IOException;
-
-/**
- *
- */
-public class NumericLongAnalyzer extends NumericAnalyzer {
-
- private final static IntObjectHashMap builtIn;
-
- static {
- builtIn = new IntObjectHashMap<>();
- builtIn.put(Integer.MAX_VALUE, new NamedAnalyzer("_long/max", AnalyzerScope.GLOBAL, new NumericLongAnalyzer(Integer.MAX_VALUE)));
- for (int i = 0; i <= 64; i += 4) {
- builtIn.put(i, new NamedAnalyzer("_long/" + i, AnalyzerScope.GLOBAL, new NumericLongAnalyzer(i)));
- }
- }
-
- public static NamedAnalyzer buildNamedAnalyzer(int precisionStep) {
- NamedAnalyzer namedAnalyzer = builtIn.get(precisionStep);
- if (namedAnalyzer == null) {
- namedAnalyzer = new NamedAnalyzer("_long/" + precisionStep, AnalyzerScope.INDEX, new NumericLongAnalyzer(precisionStep));
- }
- return namedAnalyzer;
- }
-
- private final int precisionStep;
-
- public NumericLongAnalyzer(int precisionStep) {
- this.precisionStep = precisionStep;
- }
-
- @Override
- protected NumericLongTokenizer createNumericTokenizer(char[] buffer) throws IOException {
- return new NumericLongTokenizer(precisionStep, buffer);
- }
-}
diff --git a/core/src/main/java/org/elasticsearch/index/analysis/NumericLongTokenizer.java b/core/src/main/java/org/elasticsearch/index/analysis/NumericLongTokenizer.java
deleted file mode 100644
index 63abd2d9ed4..00000000000
--- a/core/src/main/java/org/elasticsearch/index/analysis/NumericLongTokenizer.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch 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.elasticsearch.index.analysis;
-
-import org.apache.lucene.analysis.LegacyNumericTokenStream;
-
-import java.io.IOException;
-
-/**
- *
- */
-public class NumericLongTokenizer extends NumericTokenizer {
-
- public NumericLongTokenizer(int precisionStep, char[] buffer) throws IOException {
- super(new LegacyNumericTokenStream(precisionStep), buffer, null);
- }
-
- @Override
- protected void setValue(LegacyNumericTokenStream tokenStream, String value) {
- tokenStream.setLongValue(Long.parseLong(value));
- }
-}
diff --git a/core/src/main/java/org/elasticsearch/index/analysis/NumericTokenizer.java b/core/src/main/java/org/elasticsearch/index/analysis/NumericTokenizer.java
deleted file mode 100644
index 6339b11636e..00000000000
--- a/core/src/main/java/org/elasticsearch/index/analysis/NumericTokenizer.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch 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.elasticsearch.index.analysis;
-
-import org.apache.lucene.analysis.LegacyNumericTokenStream;
-import org.apache.lucene.analysis.Tokenizer;
-import org.apache.lucene.util.Attribute;
-import org.apache.lucene.util.AttributeFactory;
-import org.apache.lucene.util.AttributeImpl;
-import org.apache.lucene.util.AttributeSource;
-import org.elasticsearch.common.io.Streams;
-
-import java.io.IOException;
-import java.util.Iterator;
-
-/**
- *
- */
-public abstract class NumericTokenizer extends Tokenizer {
-
- /** Make this tokenizer get attributes from the delegate token stream. */
- private static final AttributeFactory delegatingAttributeFactory(final AttributeSource source) {
- return new AttributeFactory() {
- @Override
- public AttributeImpl createAttributeInstance(Class extends Attribute> attClass) {
- return (AttributeImpl) source.addAttribute(attClass);
- }
- };
- }
-
- private final LegacyNumericTokenStream numericTokenStream;
- private final char[] buffer;
- protected final Object extra;
- private boolean started;
-
- protected NumericTokenizer(LegacyNumericTokenStream numericTokenStream, char[] buffer, Object extra) throws IOException {
- super(delegatingAttributeFactory(numericTokenStream));
- this.numericTokenStream = numericTokenStream;
- // Add attributes from the numeric token stream, this works fine because the attribute factory delegates to numericTokenStream
- for (Iterator> it = numericTokenStream.getAttributeClassesIterator(); it.hasNext();) {
- addAttribute(it.next());
- }
- this.extra = extra;
- this.buffer = buffer;
- started = true;
- }
-
- @Override
- public void reset() throws IOException {
- super.reset();
- started = false;
- }
-
- @Override
- public final boolean incrementToken() throws IOException {
- if (!started) {
- // reset() must be idempotent, this is why we read data in incrementToken
- final int len = Streams.readFully(input, buffer);
- if (len == buffer.length && input.read() != -1) {
- throw new IOException("Cannot read numeric data larger than " + buffer.length + " chars");
- }
- setValue(numericTokenStream, new String(buffer, 0, len));
- numericTokenStream.reset();
- started = true;
- }
- return numericTokenStream.incrementToken();
- }
-
- @Override
- public void end() throws IOException {
- super.end();
- numericTokenStream.end();
- }
-
- @Override
- public void close() throws IOException {
- super.close();
- numericTokenStream.close();
- }
-
- protected abstract void setValue(LegacyNumericTokenStream tokenStream, String value);
-}
diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/ByteFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/ByteFieldMapper.java
index 68275c20f13..6036e043810 100644
--- a/core/src/main/java/org/elasticsearch/index/mapper/core/ByteFieldMapper.java
+++ b/core/src/main/java/org/elasticsearch/index/mapper/core/ByteFieldMapper.java
@@ -38,7 +38,6 @@ import org.elasticsearch.common.unit.Fuzziness;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.analysis.NamedAnalyzer;
-import org.elasticsearch.index.analysis.NumericIntegerAnalyzer;
import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.IndexNumericFieldData.NumericType;
import org.elasticsearch.index.fielddata.plain.DocValuesIndexFieldData;
@@ -85,12 +84,6 @@ public class ByteFieldMapper extends NumberFieldMapper {
return (ByteFieldMapper) fieldMapper.includeInAll(includeInAll);
}
- @Override
- protected NamedAnalyzer makeNumberAnalyzer(int precisionStep) {
- String name = precisionStep == Integer.MAX_VALUE ? "_byte/max" : ("_byte/" + precisionStep);
- return new NamedAnalyzer(name, new NumericIntegerAnalyzer(precisionStep));
- }
-
@Override
protected int maxPrecisionStep() {
return 32;
diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/DateFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/DateFieldMapper.java
index 6f4d5d90d13..9254e221432 100644
--- a/core/src/main/java/org/elasticsearch/index/mapper/core/DateFieldMapper.java
+++ b/core/src/main/java/org/elasticsearch/index/mapper/core/DateFieldMapper.java
@@ -44,7 +44,6 @@ import org.elasticsearch.common.util.LocaleUtils;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.analysis.NamedAnalyzer;
-import org.elasticsearch.index.analysis.NumericDateAnalyzer;
import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.IndexNumericFieldData.NumericType;
import org.elasticsearch.index.fielddata.plain.DocValuesIndexFieldData;
@@ -141,11 +140,6 @@ public class DateFieldMapper extends NumberFieldMapper {
return this;
}
- @Override
- protected NamedAnalyzer makeNumberAnalyzer(int precisionStep) {
- return NumericDateAnalyzer.buildNamedAnalyzer(fieldType().dateTimeFormatter, precisionStep);
- }
-
@Override
protected int maxPrecisionStep() {
return 64;
diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/DoubleFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/DoubleFieldMapper.java
index 08ec79013b5..11b1dcadb06 100644
--- a/core/src/main/java/org/elasticsearch/index/mapper/core/DoubleFieldMapper.java
+++ b/core/src/main/java/org/elasticsearch/index/mapper/core/DoubleFieldMapper.java
@@ -40,7 +40,6 @@ import org.elasticsearch.common.unit.Fuzziness;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.analysis.NamedAnalyzer;
-import org.elasticsearch.index.analysis.NumericDoubleAnalyzer;
import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.IndexNumericFieldData.NumericType;
import org.elasticsearch.index.fielddata.plain.DocValuesIndexFieldData;
@@ -87,11 +86,6 @@ public class DoubleFieldMapper extends NumberFieldMapper {
return (DoubleFieldMapper) fieldMapper.includeInAll(includeInAll);
}
- @Override
- protected NamedAnalyzer makeNumberAnalyzer(int precisionStep) {
- return NumericDoubleAnalyzer.buildNamedAnalyzer(precisionStep);
- }
-
@Override
protected int maxPrecisionStep() {
return 64;
diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/FloatFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/FloatFieldMapper.java
index a6005eb420f..c81acc34aa2 100644
--- a/core/src/main/java/org/elasticsearch/index/mapper/core/FloatFieldMapper.java
+++ b/core/src/main/java/org/elasticsearch/index/mapper/core/FloatFieldMapper.java
@@ -41,7 +41,6 @@ import org.elasticsearch.common.unit.Fuzziness;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.analysis.NamedAnalyzer;
-import org.elasticsearch.index.analysis.NumericFloatAnalyzer;
import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.IndexNumericFieldData.NumericType;
import org.elasticsearch.index.fielddata.plain.DocValuesIndexFieldData;
@@ -88,11 +87,6 @@ public class FloatFieldMapper extends NumberFieldMapper {
return (FloatFieldMapper) fieldMapper.includeInAll(includeInAll);
}
- @Override
- protected NamedAnalyzer makeNumberAnalyzer(int precisionStep) {
- return NumericFloatAnalyzer.buildNamedAnalyzer(precisionStep);
- }
-
@Override
protected int maxPrecisionStep() {
return 32;
diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/IntegerFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/IntegerFieldMapper.java
index 7bec3024f8d..c4e9ea958d1 100644
--- a/core/src/main/java/org/elasticsearch/index/mapper/core/IntegerFieldMapper.java
+++ b/core/src/main/java/org/elasticsearch/index/mapper/core/IntegerFieldMapper.java
@@ -40,7 +40,6 @@ import org.elasticsearch.common.unit.Fuzziness;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.analysis.NamedAnalyzer;
-import org.elasticsearch.index.analysis.NumericIntegerAnalyzer;
import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.IndexNumericFieldData.NumericType;
import org.elasticsearch.index.fielddata.plain.DocValuesIndexFieldData;
@@ -92,12 +91,6 @@ public class IntegerFieldMapper extends NumberFieldMapper {
context.indexSettings(), multiFieldsBuilder.build(this, context), copyTo);
return (IntegerFieldMapper) fieldMapper.includeInAll(includeInAll);
}
-
- @Override
- protected NamedAnalyzer makeNumberAnalyzer(int precisionStep) {
- return NumericIntegerAnalyzer.buildNamedAnalyzer(precisionStep);
- }
-
@Override
protected int maxPrecisionStep() {
return 32;
diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/LongFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/LongFieldMapper.java
index ce1c0b02074..05591a5b1c1 100644
--- a/core/src/main/java/org/elasticsearch/index/mapper/core/LongFieldMapper.java
+++ b/core/src/main/java/org/elasticsearch/index/mapper/core/LongFieldMapper.java
@@ -40,7 +40,6 @@ import org.elasticsearch.common.unit.Fuzziness;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.analysis.NamedAnalyzer;
-import org.elasticsearch.index.analysis.NumericLongAnalyzer;
import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.IndexNumericFieldData.NumericType;
import org.elasticsearch.index.fielddata.plain.DocValuesIndexFieldData;
@@ -92,11 +91,6 @@ public class LongFieldMapper extends NumberFieldMapper {
return (LongFieldMapper) fieldMapper.includeInAll(includeInAll);
}
- @Override
- protected NamedAnalyzer makeNumberAnalyzer(int precisionStep) {
- return NumericLongAnalyzer.buildNamedAnalyzer(precisionStep);
- }
-
@Override
protected int maxPrecisionStep() {
return 64;
diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/NumberFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/NumberFieldMapper.java
index f69eb534d41..9c12c52b47f 100644
--- a/core/src/main/java/org/elasticsearch/index/mapper/core/NumberFieldMapper.java
+++ b/core/src/main/java/org/elasticsearch/index/mapper/core/NumberFieldMapper.java
@@ -127,12 +127,8 @@ public abstract class NumberFieldMapper extends FieldMapper implements AllFieldM
if (precisionStep <= 0 || precisionStep >= maxPrecisionStep()) {
fieldType.setNumericPrecisionStep(Integer.MAX_VALUE);
}
- fieldType.setIndexAnalyzer(makeNumberAnalyzer(fieldType.numericPrecisionStep()));
- fieldType.setSearchAnalyzer(makeNumberAnalyzer(Integer.MAX_VALUE));
}
- protected abstract NamedAnalyzer makeNumberAnalyzer(int precisionStep);
-
protected abstract int maxPrecisionStep();
}
diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/ShortFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/ShortFieldMapper.java
index a25e08adc53..6902e26e0fd 100644
--- a/core/src/main/java/org/elasticsearch/index/mapper/core/ShortFieldMapper.java
+++ b/core/src/main/java/org/elasticsearch/index/mapper/core/ShortFieldMapper.java
@@ -39,7 +39,6 @@ import org.elasticsearch.common.unit.Fuzziness;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.analysis.NamedAnalyzer;
-import org.elasticsearch.index.analysis.NumericIntegerAnalyzer;
import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.IndexNumericFieldData.NumericType;
import org.elasticsearch.index.fielddata.plain.DocValuesIndexFieldData;
@@ -88,12 +87,6 @@ public class ShortFieldMapper extends NumberFieldMapper {
return (ShortFieldMapper) fieldMapper.includeInAll(includeInAll);
}
- @Override
- protected NamedAnalyzer makeNumberAnalyzer(int precisionStep) {
- String name = precisionStep == Integer.MAX_VALUE ? "_short/max" : ("_short/" + precisionStep);
- return new NamedAnalyzer(name, new NumericIntegerAnalyzer(precisionStep));
- }
-
@Override
protected int maxPrecisionStep() {
return 32;
diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/TokenCountFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/TokenCountFieldMapper.java
index 4e850176199..33744441759 100644
--- a/core/src/main/java/org/elasticsearch/index/mapper/core/TokenCountFieldMapper.java
+++ b/core/src/main/java/org/elasticsearch/index/mapper/core/TokenCountFieldMapper.java
@@ -28,7 +28,6 @@ import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.index.analysis.NamedAnalyzer;
-import org.elasticsearch.index.analysis.NumericIntegerAnalyzer;
import org.elasticsearch.index.mapper.FieldMapper;
import org.elasticsearch.index.mapper.MappedFieldType;
import org.elasticsearch.index.mapper.Mapper;
@@ -82,11 +81,6 @@ public class TokenCountFieldMapper extends IntegerFieldMapper {
return (TokenCountFieldMapper) fieldMapper.includeInAll(includeInAll);
}
- @Override
- protected NamedAnalyzer makeNumberAnalyzer(int precisionStep) {
- return NumericIntegerAnalyzer.buildNamedAnalyzer(precisionStep);
- }
-
@Override
protected int maxPrecisionStep() {
return 32;
diff --git a/core/src/main/java/org/elasticsearch/index/mapper/internal/TTLFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/internal/TTLFieldMapper.java
index aaa0bffd805..13dd7205e37 100644
--- a/core/src/main/java/org/elasticsearch/index/mapper/internal/TTLFieldMapper.java
+++ b/core/src/main/java/org/elasticsearch/index/mapper/internal/TTLFieldMapper.java
@@ -22,12 +22,12 @@ package org.elasticsearch.index.mapper.internal;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexOptions;
import org.elasticsearch.common.Strings;
+import org.elasticsearch.common.lucene.Lucene;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.AlreadyExpiredException;
-import org.elasticsearch.index.analysis.NumericLongAnalyzer;
import org.elasticsearch.index.mapper.MappedFieldType;
import org.elasticsearch.index.mapper.Mapper;
import org.elasticsearch.index.mapper.MapperParsingException;
@@ -61,9 +61,9 @@ public class TTLFieldMapper extends MetadataFieldMapper {
TTL_FIELD_TYPE.setStored(true);
TTL_FIELD_TYPE.setTokenized(false);
TTL_FIELD_TYPE.setNumericPrecisionStep(Defaults.PRECISION_STEP_64_BIT);
- TTL_FIELD_TYPE.setIndexAnalyzer(NumericLongAnalyzer.buildNamedAnalyzer(Defaults.PRECISION_STEP_64_BIT));
- TTL_FIELD_TYPE.setSearchAnalyzer(NumericLongAnalyzer.buildNamedAnalyzer(Integer.MAX_VALUE));
TTL_FIELD_TYPE.setName(NAME);
+ TTL_FIELD_TYPE.setIndexAnalyzer(Lucene.KEYWORD_ANALYZER);
+ TTL_FIELD_TYPE.setSearchAnalyzer(Lucene.KEYWORD_ANALYZER);
TTL_FIELD_TYPE.freeze();
}
diff --git a/core/src/main/java/org/elasticsearch/index/mapper/internal/TimestampFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/internal/TimestampFieldMapper.java
index d51653f2a1a..0e277d95543 100644
--- a/core/src/main/java/org/elasticsearch/index/mapper/internal/TimestampFieldMapper.java
+++ b/core/src/main/java/org/elasticsearch/index/mapper/internal/TimestampFieldMapper.java
@@ -26,9 +26,9 @@ import org.elasticsearch.action.TimestampParsingException;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.joda.FormatDateTimeFormatter;
import org.elasticsearch.common.joda.Joda;
+import org.elasticsearch.common.lucene.Lucene;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
-import org.elasticsearch.index.analysis.NumericDateAnalyzer;
import org.elasticsearch.index.mapper.MappedFieldType;
import org.elasticsearch.index.mapper.Mapper;
import org.elasticsearch.index.mapper.MapperParsingException;
@@ -65,8 +65,8 @@ public class TimestampFieldMapper extends MetadataFieldMapper {
FIELD_TYPE.setNumericPrecisionStep(Defaults.PRECISION_STEP_64_BIT);
FIELD_TYPE.setName(NAME);
FIELD_TYPE.setDateTimeFormatter(DATE_TIME_FORMATTER);
- FIELD_TYPE.setIndexAnalyzer(NumericDateAnalyzer.buildNamedAnalyzer(DATE_TIME_FORMATTER, Defaults.PRECISION_STEP_64_BIT));
- FIELD_TYPE.setSearchAnalyzer(NumericDateAnalyzer.buildNamedAnalyzer(DATE_TIME_FORMATTER, Integer.MAX_VALUE));
+ FIELD_TYPE.setIndexAnalyzer(Lucene.KEYWORD_ANALYZER);
+ FIELD_TYPE.setSearchAnalyzer(Lucene.KEYWORD_ANALYZER);
FIELD_TYPE.setHasDocValues(true);
FIELD_TYPE.freeze();
}
diff --git a/core/src/main/java/org/elasticsearch/index/mapper/ip/IpFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/ip/IpFieldMapper.java
index d1ee4307c5e..b973c8f60ee 100644
--- a/core/src/main/java/org/elasticsearch/index/mapper/ip/IpFieldMapper.java
+++ b/core/src/main/java/org/elasticsearch/index/mapper/ip/IpFieldMapper.java
@@ -42,8 +42,6 @@ import org.elasticsearch.common.unit.Fuzziness;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.index.analysis.NamedAnalyzer;
-import org.elasticsearch.index.analysis.NumericAnalyzer;
-import org.elasticsearch.index.analysis.NumericTokenizer;
import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.IndexNumericFieldData.NumericType;
import org.elasticsearch.index.fielddata.plain.DocValuesIndexFieldData;
@@ -131,12 +129,6 @@ public class IpFieldMapper extends NumberFieldMapper {
return (IpFieldMapper) fieldMapper.includeInAll(includeInAll);
}
- @Override
- protected NamedAnalyzer makeNumberAnalyzer(int precisionStep) {
- String name = precisionStep == Integer.MAX_VALUE ? "_ip/max" : ("_ip/" + precisionStep);
- return new NamedAnalyzer(name, new NumericIpAnalyzer(precisionStep));
- }
-
@Override
protected int maxPrecisionStep() {
return 64;
@@ -362,29 +354,4 @@ public class IpFieldMapper extends NumberFieldMapper {
}
- public static class NumericIpAnalyzer extends NumericAnalyzer {
-
- private final int precisionStep;
-
- public NumericIpAnalyzer(int precisionStep) {
- this.precisionStep = precisionStep;
- }
-
- @Override
- protected NumericIpTokenizer createNumericTokenizer(char[] buffer) throws IOException {
- return new NumericIpTokenizer(precisionStep, buffer);
- }
- }
-
- public static class NumericIpTokenizer extends NumericTokenizer {
-
- public NumericIpTokenizer(int precisionStep, char[] buffer) throws IOException {
- super(new LegacyNumericTokenStream(precisionStep), buffer, null);
- }
-
- @Override
- protected void setValue(LegacyNumericTokenStream tokenStream, String value) {
- tokenStream.setLongValue(ipToLong(value));
- }
- }
}
diff --git a/core/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java b/core/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java
index 8e3b39a9ee8..1973a6a4772 100644
--- a/core/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java
+++ b/core/src/main/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilder.java
@@ -52,8 +52,10 @@ import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.VersionType;
-import org.elasticsearch.index.analysis.Analysis;
import org.elasticsearch.index.mapper.MappedFieldType;
+import org.elasticsearch.index.mapper.core.KeywordFieldMapper.KeywordFieldType;
+import org.elasticsearch.index.mapper.core.StringFieldMapper.StringFieldType;
+import org.elasticsearch.index.mapper.core.TextFieldMapper.TextFieldType;
import org.elasticsearch.index.mapper.internal.UidFieldMapper;
import org.elasticsearch.search.internal.SearchContext;
@@ -62,7 +64,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -94,6 +95,9 @@ public class MoreLikeThisQueryBuilder extends AbstractQueryBuilder> SUPPORTED_FIELD_TYPES = new HashSet<>(
+ Arrays.asList(StringFieldType.class, TextFieldType.class, KeywordFieldType.class));
+
private interface Field {
ParseField FIELDS = new ParseField("fields");
ParseField LIKE = new ParseField("like");
@@ -1032,12 +1036,18 @@ public class MoreLikeThisQueryBuilder extends AbstractQueryBuilder removeUnsupportedFields(List moreLikeFields, Analyzer analyzer, boolean failOnUnsupportedField) throws IOException {
- for (Iterator it = moreLikeFields.iterator(); it.hasNext(); ) {
- final String fieldName = it.next();
- if (!Analysis.generatesCharacterTokenStream(analyzer, fieldName)) {
- if (failOnUnsupportedField) {
- throw new IllegalArgumentException("more_like_this doesn't support binary/numeric fields: [" + fieldName + "]");
- } else {
- it.remove();
- }
- }
- }
- return moreLikeFields;
- }
-
private Query handleItems(QueryShardContext context, MoreLikeThisQuery mltQuery, Item[] likeItems, Item[] unlikeItems,
boolean include, List moreLikeFields, boolean useDefaultField) throws IOException {
// set default index, type and fields if not specified
diff --git a/core/src/test/java/org/elasticsearch/index/analysis/NumericAnalyzerTests.java b/core/src/test/java/org/elasticsearch/index/analysis/NumericAnalyzerTests.java
deleted file mode 100644
index 10d3d3554dd..00000000000
--- a/core/src/test/java/org/elasticsearch/index/analysis/NumericAnalyzerTests.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch 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.elasticsearch.index.analysis;
-
-import org.apache.lucene.analysis.LegacyNumericTokenStream;
-import org.apache.lucene.analysis.LegacyNumericTokenStream.LegacyNumericTermAttribute;
-import org.apache.lucene.analysis.TokenStream;
-import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
-import org.elasticsearch.test.ESTestCase;
-
-import java.io.IOException;
-
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.is;
-
-public class NumericAnalyzerTests extends ESTestCase {
- public void testAttributeEqual() throws IOException {
- final int precisionStep = 8;
- final double value = randomDouble();
- NumericDoubleAnalyzer analyzer = new NumericDoubleAnalyzer(precisionStep);
-
- final TokenStream ts1 = analyzer.tokenStream("dummy", String.valueOf(value));
- final LegacyNumericTokenStream ts2 = new LegacyNumericTokenStream(precisionStep);
- ts2.setDoubleValue(value);
- final LegacyNumericTermAttribute numTerm1 = ts1.addAttribute(LegacyNumericTermAttribute.class);
- final LegacyNumericTermAttribute numTerm2 = ts1.addAttribute(LegacyNumericTermAttribute.class);
- final PositionIncrementAttribute posInc1 = ts1.addAttribute(PositionIncrementAttribute.class);
- final PositionIncrementAttribute posInc2 = ts1.addAttribute(PositionIncrementAttribute.class);
- ts1.reset();
- ts2.reset();
- while (ts1.incrementToken()) {
- assertThat(ts2.incrementToken(), is(true));
- assertThat(posInc1, equalTo(posInc2));
- // can't use equalTo directly on the numeric attribute cause it doesn't implement equals (LUCENE-5070)
- assertThat(numTerm1.getRawValue(), equalTo(numTerm2.getRawValue()));
- assertThat(numTerm2.getShift(), equalTo(numTerm2.getShift()));
- }
- assertThat(ts2.incrementToken(), is(false));
- ts1.end();
- ts2.end();
- }
-}
diff --git a/core/src/test/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilderTests.java
index 645fd00d050..31a11e36b0a 100644
--- a/core/src/test/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilderTests.java
+++ b/core/src/test/java/org/elasticsearch/index/query/MoreLikeThisQueryBuilderTests.java
@@ -272,7 +272,7 @@ public class MoreLikeThisQueryBuilderTests extends AbstractQueryTestCase