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()));
|
return new TermQuery(new Term("_feature", name()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Query nullValueQuery() {
|
|
||||||
if (nullValue() == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return termQuery(nullValue(), null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||||
failIfNoDocValues();
|
failIfNoDocValues();
|
||||||
|
|
|
@ -135,14 +135,6 @@ public class ICUCollationKeywordFieldMapper extends FieldMapper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Query nullValueQuery() {
|
|
||||||
if (nullValue() == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return termQuery(nullValue(), null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||||
failIfNoDocValues();
|
failIfNoDocValues();
|
||||||
|
|
|
@ -19,12 +19,8 @@
|
||||||
|
|
||||||
package org.apache.lucene.queries;
|
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.BooleanClause.Occur;
|
||||||
import org.apache.lucene.search.Query;
|
|
||||||
import org.elasticsearch.common.lucene.search.Queries;
|
import org.elasticsearch.common.lucene.search.Queries;
|
||||||
import org.elasticsearch.index.mapper.MappedFieldType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extended version of {@link CommonTermsQuery} that allows to pass in a
|
* 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 {
|
public class ExtendedCommonTermsQuery extends CommonTermsQuery {
|
||||||
|
|
||||||
private final MappedFieldType fieldType;
|
public ExtendedCommonTermsQuery(Occur highFreqOccur, Occur lowFreqOccur, float maxTermFrequency) {
|
||||||
|
|
||||||
public ExtendedCommonTermsQuery(Occur highFreqOccur, Occur lowFreqOccur, float maxTermFrequency, MappedFieldType fieldType) {
|
|
||||||
super(highFreqOccur, lowFreqOccur, maxTermFrequency);
|
super(highFreqOccur, lowFreqOccur, maxTermFrequency);
|
||||||
this.fieldType = fieldType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String lowFreqMinNumShouldMatchSpec;
|
private String lowFreqMinNumShouldMatchSpec;
|
||||||
|
@ -80,16 +73,4 @@ public class ExtendedCommonTermsQuery extends CommonTermsQuery {
|
||||||
return this.maxTermFrequency;
|
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
|
@Override
|
||||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||||
failIfNoDocValues();
|
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() + "]");
|
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);
|
public abstract Query existsQuery(QueryShardContext context);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -382,12 +375,6 @@ public abstract class MappedFieldType extends FieldType {
|
||||||
return Relation.INTERSECTS;
|
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.
|
/** @throws IllegalArgumentException if the fielddata is not supported on this type.
|
||||||
* An IllegalArgumentException is needed in order to return an http error 400
|
* 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}
|
* 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.TokenFilter;
|
||||||
import org.apache.lucene.analysis.ngram.EdgeNGramTokenFilter;
|
import org.apache.lucene.analysis.ngram.EdgeNGramTokenFilter;
|
||||||
import org.apache.lucene.document.Field;
|
import org.apache.lucene.document.Field;
|
||||||
import org.apache.lucene.document.FieldType;
|
|
||||||
import org.apache.lucene.index.IndexOptions;
|
import org.apache.lucene.index.IndexOptions;
|
||||||
import org.apache.lucene.index.IndexableField;
|
import org.apache.lucene.index.IndexableField;
|
||||||
import org.apache.lucene.index.Term;
|
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
|
@Override
|
||||||
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) {
|
||||||
if (fielddata == false) {
|
if (fielddata == false) {
|
||||||
|
|
|
@ -371,8 +371,7 @@ public class CommonTermsQueryBuilder extends AbstractQueryBuilder<CommonTermsQue
|
||||||
Occur highFreqOccur = highFreqOperator.toBooleanClauseOccur();
|
Occur highFreqOccur = highFreqOperator.toBooleanClauseOccur();
|
||||||
Occur lowFreqOccur = lowFreqOperator.toBooleanClauseOccur();
|
Occur lowFreqOccur = lowFreqOperator.toBooleanClauseOccur();
|
||||||
|
|
||||||
ExtendedCommonTermsQuery commonsQuery = new ExtendedCommonTermsQuery(highFreqOccur, lowFreqOccur,
|
ExtendedCommonTermsQuery commonsQuery = new ExtendedCommonTermsQuery(highFreqOccur, lowFreqOccur, cutoffFrequency);
|
||||||
cutoffFrequency, fieldType);
|
|
||||||
return parseQueryString(commonsQuery, text, field, analyzerObj, lowFreqMinimumShouldMatch, highFreqMinimumShouldMatch);
|
return parseQueryString(commonsQuery, text, field, analyzerObj, lowFreqMinimumShouldMatch, highFreqMinimumShouldMatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
package org.elasticsearch.index.search;
|
package org.elasticsearch.index.search;
|
||||||
|
|
||||||
import org.apache.lucene.analysis.Analyzer;
|
import org.apache.lucene.analysis.Analyzer;
|
||||||
import org.apache.lucene.analysis.miscellaneous.DisableGraphAttribute;
|
|
||||||
import org.apache.lucene.analysis.TokenStream;
|
import org.apache.lucene.analysis.TokenStream;
|
||||||
|
import org.apache.lucene.analysis.miscellaneous.DisableGraphAttribute;
|
||||||
import org.apache.lucene.index.IndexOptions;
|
import org.apache.lucene.index.IndexOptions;
|
||||||
import org.apache.lucene.index.Term;
|
import org.apache.lucene.index.Term;
|
||||||
import org.apache.lucene.queries.ExtendedCommonTermsQuery;
|
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.BooleanClause.Occur;
|
||||||
import org.apache.lucene.search.BooleanQuery;
|
import org.apache.lucene.search.BooleanQuery;
|
||||||
import org.apache.lucene.search.BoostQuery;
|
import org.apache.lucene.search.BoostQuery;
|
||||||
import org.apache.lucene.search.DisjunctionMaxQuery;
|
|
||||||
import org.apache.lucene.search.FuzzyQuery;
|
import org.apache.lucene.search.FuzzyQuery;
|
||||||
import org.apache.lucene.search.MultiPhraseQuery;
|
import org.apache.lucene.search.MultiPhraseQuery;
|
||||||
import org.apache.lucene.search.MultiTermQuery;
|
import org.apache.lucene.search.MultiTermQuery;
|
||||||
|
@ -283,7 +282,7 @@ public class MatchQuery {
|
||||||
if (commonTermsCutoff == null) {
|
if (commonTermsCutoff == null) {
|
||||||
query = builder.createBooleanQuery(field, value.toString(), occur);
|
query = builder.createBooleanQuery(field, value.toString(), occur);
|
||||||
} else {
|
} else {
|
||||||
query = builder.createCommonTermsQuery(field, value.toString(), occur, occur, commonTermsCutoff, fieldType);
|
query = builder.createCommonTermsQuery(field, value.toString(), occur, occur, commonTermsCutoff);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PHRASE:
|
case PHRASE:
|
||||||
|
@ -463,20 +462,23 @@ public class MatchQuery {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Query createCommonTermsQuery(String field, String queryText, Occur highFreqOccur, Occur lowFreqOccur, float
|
public Query createCommonTermsQuery(String field, String queryText,
|
||||||
maxTermFrequency, MappedFieldType fieldType) {
|
Occur highFreqOccur,
|
||||||
|
Occur lowFreqOccur,
|
||||||
|
float maxTermFrequency) {
|
||||||
Query booleanQuery = createBooleanQuery(field, queryText, lowFreqOccur);
|
Query booleanQuery = createBooleanQuery(field, queryText, lowFreqOccur);
|
||||||
if (booleanQuery != null && booleanQuery instanceof BooleanQuery) {
|
if (booleanQuery != null && booleanQuery instanceof BooleanQuery) {
|
||||||
BooleanQuery bq = (BooleanQuery) booleanQuery;
|
BooleanQuery bq = (BooleanQuery) booleanQuery;
|
||||||
return boolToExtendedCommonTermsQuery(bq, highFreqOccur, lowFreqOccur, maxTermFrequency, fieldType);
|
return boolToExtendedCommonTermsQuery(bq, highFreqOccur, lowFreqOccur, maxTermFrequency);
|
||||||
}
|
}
|
||||||
return booleanQuery;
|
return booleanQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Query boolToExtendedCommonTermsQuery(BooleanQuery bq, Occur highFreqOccur, Occur lowFreqOccur, float
|
private Query boolToExtendedCommonTermsQuery(BooleanQuery bq,
|
||||||
maxTermFrequency, MappedFieldType fieldType) {
|
Occur highFreqOccur,
|
||||||
ExtendedCommonTermsQuery query = new ExtendedCommonTermsQuery(highFreqOccur, lowFreqOccur, maxTermFrequency,
|
Occur lowFreqOccur,
|
||||||
fieldType);
|
float maxTermFrequency) {
|
||||||
|
ExtendedCommonTermsQuery query = new ExtendedCommonTermsQuery(highFreqOccur, lowFreqOccur, maxTermFrequency);
|
||||||
for (BooleanClause clause : bq.clauses()) {
|
for (BooleanClause clause : bq.clauses()) {
|
||||||
if (!(clause.getQuery() instanceof TermQuery)) {
|
if (!(clause.getQuery() instanceof TermQuery)) {
|
||||||
return bq;
|
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
|
@Override
|
||||||
protected Query newMatchAllDocsQuery() {
|
protected Query newMatchAllDocsQuery() {
|
||||||
return Queries.newMatchAllQuery();
|
return Queries.newMatchAllQuery();
|
||||||
|
|
|
@ -105,14 +105,6 @@ public class FakeStringFieldMapper extends FieldMapper {
|
||||||
return CONTENT_TYPE;
|
return CONTENT_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Query nullValueQuery() {
|
|
||||||
if (nullValue() == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return termQuery(nullValue(), null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Query existsQuery(QueryShardContext context) {
|
public Query existsQuery(QueryShardContext context) {
|
||||||
if (hasDocValues()) {
|
if (hasDocValues()) {
|
||||||
|
@ -136,7 +128,7 @@ public class FakeStringFieldMapper extends FieldMapper {
|
||||||
} else {
|
} else {
|
||||||
value = context.parser().textOrNull();
|
value = context.parser().textOrNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue