Remove unused query methods from MappedFieldType. (#30987)
* Remove MappedFieldType#nullValueQuery, as it is now unused. * Remove MappedFieldType#queryStringTermQuery, as it is never overridden.
This commit is contained in:
parent
4f66b9a27c
commit
cd0a375414
|
@ -163,14 +163,6 @@ public class FeatureFieldMapper extends FieldMapper {
|
|||
return new TermQuery(new Term("_feature", name()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query nullValueQuery() {
|
||||
if (nullValue() == null) {
|
||||
return null;
|
||||
}
|
||||
return termQuery(nullValue(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||
failIfNoDocValues();
|
||||
|
|
|
@ -135,14 +135,6 @@ public class ICUCollationKeywordFieldMapper extends FieldMapper {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query nullValueQuery() {
|
||||
if (nullValue() == null) {
|
||||
return null;
|
||||
}
|
||||
return termQuery(nullValue(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||
failIfNoDocValues();
|
||||
|
|
|
@ -19,12 +19,8 @@
|
|||
|
||||
package org.apache.lucene.queries;
|
||||
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.index.TermContext;
|
||||
import org.apache.lucene.search.BooleanClause.Occur;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.elasticsearch.common.lucene.search.Queries;
|
||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
||||
|
||||
/**
|
||||
* Extended version of {@link CommonTermsQuery} that allows to pass in a
|
||||
|
@ -33,11 +29,8 @@ import org.elasticsearch.index.mapper.MappedFieldType;
|
|||
*/
|
||||
public class ExtendedCommonTermsQuery extends CommonTermsQuery {
|
||||
|
||||
private final MappedFieldType fieldType;
|
||||
|
||||
public ExtendedCommonTermsQuery(Occur highFreqOccur, Occur lowFreqOccur, float maxTermFrequency, MappedFieldType fieldType) {
|
||||
public ExtendedCommonTermsQuery(Occur highFreqOccur, Occur lowFreqOccur, float maxTermFrequency) {
|
||||
super(highFreqOccur, lowFreqOccur, maxTermFrequency);
|
||||
this.fieldType = fieldType;
|
||||
}
|
||||
|
||||
private String lowFreqMinNumShouldMatchSpec;
|
||||
|
@ -80,16 +73,4 @@ public class ExtendedCommonTermsQuery extends CommonTermsQuery {
|
|||
return this.maxTermFrequency;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Query newTermQuery(Term term, TermContext context) {
|
||||
if (fieldType == null) {
|
||||
return super.newTermQuery(term, context);
|
||||
}
|
||||
final Query query = fieldType.queryStringTermQuery(term);
|
||||
if (query == null) {
|
||||
return super.newTermQuery(term, context);
|
||||
} else {
|
||||
return query;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -223,14 +223,6 @@ public final class KeywordFieldMapper extends FieldMapper {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query nullValueQuery() {
|
||||
if (nullValue() == null) {
|
||||
return null;
|
||||
}
|
||||
return termQuery(nullValue(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||
failIfNoDocValues();
|
||||
|
|
|
@ -351,13 +351,6 @@ public abstract class MappedFieldType extends FieldType {
|
|||
throw new QueryShardException(context, "Can only use regexp queries on keyword and text fields - not on [" + name + "] which is of type [" + typeName() + "]");
|
||||
}
|
||||
|
||||
public Query nullValueQuery() {
|
||||
if (nullValue == null) {
|
||||
return null;
|
||||
}
|
||||
return new ConstantScoreQuery(termQuery(nullValue, null));
|
||||
}
|
||||
|
||||
public abstract Query existsQuery(QueryShardContext context);
|
||||
|
||||
/**
|
||||
|
@ -382,12 +375,6 @@ public abstract class MappedFieldType extends FieldType {
|
|||
return Relation.INTERSECTS;
|
||||
}
|
||||
|
||||
/** A term query to use when parsing a query string. Can return {@code null}. */
|
||||
@Nullable
|
||||
public Query queryStringTermQuery(Term term) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @throws IllegalArgumentException if the fielddata is not supported on this type.
|
||||
* An IllegalArgumentException is needed in order to return an http error 400
|
||||
* when this error occurs in a request. see: {@link org.elasticsearch.ExceptionsHelper#status}
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.apache.lucene.analysis.AnalyzerWrapper;
|
|||
import org.apache.lucene.analysis.TokenFilter;
|
||||
import org.apache.lucene.analysis.ngram.EdgeNGramTokenFilter;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.FieldType;
|
||||
import org.apache.lucene.index.IndexOptions;
|
||||
import org.apache.lucene.index.IndexableField;
|
||||
import org.apache.lucene.index.Term;
|
||||
|
@ -471,14 +470,6 @@ public class TextFieldMapper extends FieldMapper {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query nullValueQuery() {
|
||||
if (nullValue() == null) {
|
||||
return null;
|
||||
}
|
||||
return termQuery(nullValue(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||
if (fielddata == false) {
|
||||
|
|
|
@ -371,8 +371,7 @@ public class CommonTermsQueryBuilder extends AbstractQueryBuilder<CommonTermsQue
|
|||
Occur highFreqOccur = highFreqOperator.toBooleanClauseOccur();
|
||||
Occur lowFreqOccur = lowFreqOperator.toBooleanClauseOccur();
|
||||
|
||||
ExtendedCommonTermsQuery commonsQuery = new ExtendedCommonTermsQuery(highFreqOccur, lowFreqOccur,
|
||||
cutoffFrequency, fieldType);
|
||||
ExtendedCommonTermsQuery commonsQuery = new ExtendedCommonTermsQuery(highFreqOccur, lowFreqOccur, cutoffFrequency);
|
||||
return parseQueryString(commonsQuery, text, field, analyzerObj, lowFreqMinimumShouldMatch, highFreqMinimumShouldMatch);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
package org.elasticsearch.index.search;
|
||||
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.analysis.miscellaneous.DisableGraphAttribute;
|
||||
import org.apache.lucene.analysis.TokenStream;
|
||||
import org.apache.lucene.analysis.miscellaneous.DisableGraphAttribute;
|
||||
import org.apache.lucene.index.IndexOptions;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.queries.ExtendedCommonTermsQuery;
|
||||
|
@ -29,7 +29,6 @@ import org.apache.lucene.search.BooleanClause;
|
|||
import org.apache.lucene.search.BooleanClause.Occur;
|
||||
import org.apache.lucene.search.BooleanQuery;
|
||||
import org.apache.lucene.search.BoostQuery;
|
||||
import org.apache.lucene.search.DisjunctionMaxQuery;
|
||||
import org.apache.lucene.search.FuzzyQuery;
|
||||
import org.apache.lucene.search.MultiPhraseQuery;
|
||||
import org.apache.lucene.search.MultiTermQuery;
|
||||
|
@ -283,7 +282,7 @@ public class MatchQuery {
|
|||
if (commonTermsCutoff == null) {
|
||||
query = builder.createBooleanQuery(field, value.toString(), occur);
|
||||
} else {
|
||||
query = builder.createCommonTermsQuery(field, value.toString(), occur, occur, commonTermsCutoff, fieldType);
|
||||
query = builder.createCommonTermsQuery(field, value.toString(), occur, occur, commonTermsCutoff);
|
||||
}
|
||||
break;
|
||||
case PHRASE:
|
||||
|
@ -463,20 +462,23 @@ public class MatchQuery {
|
|||
}
|
||||
}
|
||||
|
||||
public Query createCommonTermsQuery(String field, String queryText, Occur highFreqOccur, Occur lowFreqOccur, float
|
||||
maxTermFrequency, MappedFieldType fieldType) {
|
||||
public Query createCommonTermsQuery(String field, String queryText,
|
||||
Occur highFreqOccur,
|
||||
Occur lowFreqOccur,
|
||||
float maxTermFrequency) {
|
||||
Query booleanQuery = createBooleanQuery(field, queryText, lowFreqOccur);
|
||||
if (booleanQuery != null && booleanQuery instanceof BooleanQuery) {
|
||||
BooleanQuery bq = (BooleanQuery) booleanQuery;
|
||||
return boolToExtendedCommonTermsQuery(bq, highFreqOccur, lowFreqOccur, maxTermFrequency, fieldType);
|
||||
return boolToExtendedCommonTermsQuery(bq, highFreqOccur, lowFreqOccur, maxTermFrequency);
|
||||
}
|
||||
return booleanQuery;
|
||||
}
|
||||
|
||||
private Query boolToExtendedCommonTermsQuery(BooleanQuery bq, Occur highFreqOccur, Occur lowFreqOccur, float
|
||||
maxTermFrequency, MappedFieldType fieldType) {
|
||||
ExtendedCommonTermsQuery query = new ExtendedCommonTermsQuery(highFreqOccur, lowFreqOccur, maxTermFrequency,
|
||||
fieldType);
|
||||
private Query boolToExtendedCommonTermsQuery(BooleanQuery bq,
|
||||
Occur highFreqOccur,
|
||||
Occur lowFreqOccur,
|
||||
float maxTermFrequency) {
|
||||
ExtendedCommonTermsQuery query = new ExtendedCommonTermsQuery(highFreqOccur, lowFreqOccur, maxTermFrequency);
|
||||
for (BooleanClause clause : bq.clauses()) {
|
||||
if (!(clause.getQuery() instanceof TermQuery)) {
|
||||
return bq;
|
||||
|
|
|
@ -272,17 +272,6 @@ public class QueryStringQueryParser extends XQueryParser {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Query newTermQuery(Term term) {
|
||||
if (currentFieldType != null) {
|
||||
Query termQuery = currentFieldType.queryStringTermQuery(term);
|
||||
if (termQuery != null) {
|
||||
return termQuery;
|
||||
}
|
||||
}
|
||||
return super.newTermQuery(term);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Query newMatchAllDocsQuery() {
|
||||
return Queries.newMatchAllQuery();
|
||||
|
|
|
@ -105,14 +105,6 @@ public class FakeStringFieldMapper extends FieldMapper {
|
|||
return CONTENT_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query nullValueQuery() {
|
||||
if (nullValue() == null) {
|
||||
return null;
|
||||
}
|
||||
return termQuery(nullValue(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query existsQuery(QueryShardContext context) {
|
||||
if (hasDocValues()) {
|
||||
|
@ -136,7 +128,7 @@ public class FakeStringFieldMapper extends FieldMapper {
|
|||
} else {
|
||||
value = context.parser().textOrNull();
|
||||
}
|
||||
|
||||
|
||||
if (value == null) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue