Skip to content

Commit 73dcb33

Browse files
committed
Remove MappedFieldType#queryStringTermQuery, as it is never overridden.
1 parent 83a99ff commit 73dcb33

File tree

5 files changed

+14
-49
lines changed

5 files changed

+14
-49
lines changed

server/src/main/java/org/apache/lucene/queries/ExtendedCommonTermsQuery.java

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,8 @@
1919

2020
package org.apache.lucene.queries;
2121

22-
import org.apache.lucene.index.Term;
23-
import org.apache.lucene.index.TermContext;
2422
import org.apache.lucene.search.BooleanClause.Occur;
25-
import org.apache.lucene.search.Query;
2623
import org.elasticsearch.common.lucene.search.Queries;
27-
import org.elasticsearch.index.mapper.MappedFieldType;
2824

2925
/**
3026
* Extended version of {@link CommonTermsQuery} that allows to pass in a
@@ -33,11 +29,8 @@
3329
*/
3430
public class ExtendedCommonTermsQuery extends CommonTermsQuery {
3531

36-
private final MappedFieldType fieldType;
37-
38-
public ExtendedCommonTermsQuery(Occur highFreqOccur, Occur lowFreqOccur, float maxTermFrequency, MappedFieldType fieldType) {
32+
public ExtendedCommonTermsQuery(Occur highFreqOccur, Occur lowFreqOccur, float maxTermFrequency) {
3933
super(highFreqOccur, lowFreqOccur, maxTermFrequency);
40-
this.fieldType = fieldType;
4134
}
4235

4336
private String lowFreqMinNumShouldMatchSpec;
@@ -80,16 +73,4 @@ public float getMaxTermFrequency() {
8073
return this.maxTermFrequency;
8174
}
8275

83-
@Override
84-
protected Query newTermQuery(Term term, TermContext context) {
85-
if (fieldType == null) {
86-
return super.newTermQuery(term, context);
87-
}
88-
final Query query = fieldType.queryStringTermQuery(term);
89-
if (query == null) {
90-
return super.newTermQuery(term, context);
91-
} else {
92-
return query;
93-
}
94-
}
9576
}

server/src/main/java/org/elasticsearch/index/mapper/MappedFieldType.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,6 @@ public Relation isFieldWithinQuery(
375375
return Relation.INTERSECTS;
376376
}
377377

378-
/** A term query to use when parsing a query string. Can return {@code null}. */
379-
@Nullable
380-
public Query queryStringTermQuery(Term term) {
381-
return null;
382-
}
383-
384378
/** @throws IllegalArgumentException if the fielddata is not supported on this type.
385379
* An IllegalArgumentException is needed in order to return an http error 400
386380
* when this error occurs in a request. see: {@link org.elasticsearch.ExceptionsHelper#status}

server/src/main/java/org/elasticsearch/index/query/CommonTermsQueryBuilder.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,7 @@ protected Query doToQuery(QueryShardContext context) throws IOException {
371371
Occur highFreqOccur = highFreqOperator.toBooleanClauseOccur();
372372
Occur lowFreqOccur = lowFreqOperator.toBooleanClauseOccur();
373373

374-
ExtendedCommonTermsQuery commonsQuery = new ExtendedCommonTermsQuery(highFreqOccur, lowFreqOccur,
375-
cutoffFrequency, fieldType);
374+
ExtendedCommonTermsQuery commonsQuery = new ExtendedCommonTermsQuery(highFreqOccur, lowFreqOccur, cutoffFrequency);
376375
return parseQueryString(commonsQuery, text, field, analyzerObj, lowFreqMinimumShouldMatch, highFreqMinimumShouldMatch);
377376
}
378377

server/src/main/java/org/elasticsearch/index/search/MatchQuery.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,15 @@
2020
package org.elasticsearch.index.search;
2121

2222
import org.apache.lucene.analysis.Analyzer;
23-
import org.apache.lucene.analysis.miscellaneous.DisableGraphAttribute;
2423
import org.apache.lucene.analysis.TokenStream;
24+
import org.apache.lucene.analysis.miscellaneous.DisableGraphAttribute;
2525
import org.apache.lucene.index.IndexOptions;
2626
import org.apache.lucene.index.Term;
2727
import org.apache.lucene.queries.ExtendedCommonTermsQuery;
2828
import org.apache.lucene.search.BooleanClause;
2929
import org.apache.lucene.search.BooleanClause.Occur;
3030
import org.apache.lucene.search.BooleanQuery;
3131
import org.apache.lucene.search.BoostQuery;
32-
import org.apache.lucene.search.DisjunctionMaxQuery;
3332
import org.apache.lucene.search.FuzzyQuery;
3433
import org.apache.lucene.search.MultiPhraseQuery;
3534
import org.apache.lucene.search.MultiTermQuery;
@@ -283,7 +282,7 @@ public Query parse(Type type, String fieldName, Object value) throws IOException
283282
if (commonTermsCutoff == null) {
284283
query = builder.createBooleanQuery(field, value.toString(), occur);
285284
} else {
286-
query = builder.createCommonTermsQuery(field, value.toString(), occur, occur, commonTermsCutoff, fieldType);
285+
query = builder.createCommonTermsQuery(field, value.toString(), occur, occur, commonTermsCutoff);
287286
}
288287
break;
289288
case PHRASE:
@@ -463,20 +462,23 @@ private Query toSpanQueryPrefix(SpanQuery query, float boost) {
463462
}
464463
}
465464

466-
public Query createCommonTermsQuery(String field, String queryText, Occur highFreqOccur, Occur lowFreqOccur, float
467-
maxTermFrequency, MappedFieldType fieldType) {
465+
public Query createCommonTermsQuery(String field, String queryText,
466+
Occur highFreqOccur,
467+
Occur lowFreqOccur,
468+
float maxTermFrequency) {
468469
Query booleanQuery = createBooleanQuery(field, queryText, lowFreqOccur);
469470
if (booleanQuery != null && booleanQuery instanceof BooleanQuery) {
470471
BooleanQuery bq = (BooleanQuery) booleanQuery;
471-
return boolToExtendedCommonTermsQuery(bq, highFreqOccur, lowFreqOccur, maxTermFrequency, fieldType);
472+
return boolToExtendedCommonTermsQuery(bq, highFreqOccur, lowFreqOccur, maxTermFrequency);
472473
}
473474
return booleanQuery;
474475
}
475476

476-
private Query boolToExtendedCommonTermsQuery(BooleanQuery bq, Occur highFreqOccur, Occur lowFreqOccur, float
477-
maxTermFrequency, MappedFieldType fieldType) {
478-
ExtendedCommonTermsQuery query = new ExtendedCommonTermsQuery(highFreqOccur, lowFreqOccur, maxTermFrequency,
479-
fieldType);
477+
private Query boolToExtendedCommonTermsQuery(BooleanQuery bq,
478+
Occur highFreqOccur,
479+
Occur lowFreqOccur,
480+
float maxTermFrequency) {
481+
ExtendedCommonTermsQuery query = new ExtendedCommonTermsQuery(highFreqOccur, lowFreqOccur, maxTermFrequency);
480482
for (BooleanClause clause : bq.clauses()) {
481483
if (!(clause.getQuery() instanceof TermQuery)) {
482484
return bq;

server/src/main/java/org/elasticsearch/index/search/QueryStringQueryParser.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -272,17 +272,6 @@ private Map<String, Float> extractMultiFields(String field, boolean quoted) {
272272
}
273273
}
274274

275-
@Override
276-
protected Query newTermQuery(Term term) {
277-
if (currentFieldType != null) {
278-
Query termQuery = currentFieldType.queryStringTermQuery(term);
279-
if (termQuery != null) {
280-
return termQuery;
281-
}
282-
}
283-
return super.newTermQuery(term);
284-
}
285-
286275
@Override
287276
protected Query newMatchAllDocsQuery() {
288277
return Queries.newMatchAllQuery();

0 commit comments

Comments
 (0)