Skip to content

Commit 7d0d50d

Browse files
Remove dead code from o.e.index.query (#116148)
Just a bunch of obvious dead code removal.
1 parent 409fb8d commit 7d0d50d

19 files changed

+4
-320
lines changed

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

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.elasticsearch.common.geo.ShapeRelation;
2424
import org.elasticsearch.common.io.stream.StreamInput;
2525
import org.elasticsearch.common.io.stream.StreamOutput;
26-
import org.elasticsearch.common.logging.DeprecationLogger;
2726
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
2827
import org.elasticsearch.common.xcontent.XContentHelper;
2928
import org.elasticsearch.geometry.Geometry;
@@ -44,10 +43,6 @@
4443
* Base {@link QueryBuilder} that builds a Geometry Query
4544
*/
4645
public abstract class AbstractGeometryQueryBuilder<QB extends AbstractGeometryQueryBuilder<QB>> extends AbstractQueryBuilder<QB> {
47-
static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Types are deprecated in [geo_shape] queries. "
48-
+ "The type should no longer be specified in the [indexed_shape] section.";
49-
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(AbstractGeometryQueryBuilder.class);
50-
5146
public static final String DEFAULT_SHAPE_INDEX_NAME = "shapes";
5247
public static final String DEFAULT_SHAPE_FIELD_NAME = "shape";
5348
public static final ShapeRelation DEFAULT_SHAPE_RELATION = ShapeRelation.INTERSECTS;
@@ -59,7 +54,6 @@ public abstract class AbstractGeometryQueryBuilder<QB extends AbstractGeometryQu
5954
protected static final ParseField RELATION_FIELD = new ParseField("relation");
6055
protected static final ParseField INDEXED_SHAPE_FIELD = new ParseField("indexed_shape");
6156
protected static final ParseField SHAPE_ID_FIELD = new ParseField("id");
62-
protected static final ParseField SHAPE_TYPE_FIELD = new ParseField("type");
6357
protected static final ParseField SHAPE_INDEX_FIELD = new ParseField("index");
6458
protected static final ParseField SHAPE_PATH_FIELD = new ParseField("path");
6559
protected static final ParseField SHAPE_ROUTING_FIELD = new ParseField("routing");
@@ -224,13 +218,6 @@ public Geometry shape() {
224218
return shape;
225219
}
226220

227-
/**
228-
* @return the ID of the indexed Shape that will be used in the Query
229-
*/
230-
public String indexedShapeId() {
231-
return indexedShapeId;
232-
}
233-
234221
/**
235222
* Sets the name of the index where the indexed Shape can be found
236223
*
@@ -243,14 +230,6 @@ public QB indexedShapeIndex(String indexedShapeIndex) {
243230
return (QB) this;
244231
}
245232

246-
/**
247-
* @return the index name for the indexed Shape that will be used in the
248-
* Query
249-
*/
250-
public String indexedShapeIndex() {
251-
return indexedShapeIndex;
252-
}
253-
254233
/**
255234
* Sets the path of the field in the indexed Shape document that has the Shape itself
256235
*
@@ -282,14 +261,6 @@ public QB indexedShapeRouting(String indexedShapeRouting) {
282261
return (QB) this;
283262
}
284263

285-
/**
286-
* @return the optional routing to the indexed Shape that will be used in the
287-
* Query
288-
*/
289-
public String indexedShapeRouting() {
290-
return indexedShapeRouting;
291-
}
292-
293264
/**
294265
* Sets the relation of query shape and indexed shape.
295266
*
@@ -322,15 +293,6 @@ public AbstractGeometryQueryBuilder<QB> ignoreUnmapped(boolean ignoreUnmapped) {
322293
return this;
323294
}
324295

325-
/**
326-
* Gets whether the query builder will ignore unmapped fields (and run a
327-
* {@link MatchNoDocsQuery} in place of this query) or throw an exception if
328-
* the field is unmapped.
329-
*/
330-
public boolean ignoreUnmapped() {
331-
return ignoreUnmapped;
332-
}
333-
334296
/** builds the appropriate lucene shape query */
335297
protected abstract Query buildShapeQuery(SearchExecutionContext context, MappedFieldType fieldType);
336298

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -231,23 +231,11 @@ public CombinedFieldsQueryBuilder zeroTermsQuery(ZeroTermsQueryOption zeroTermsQ
231231
return this;
232232
}
233233

234-
public ZeroTermsQueryOption zeroTermsQuery() {
235-
return zeroTermsQuery;
236-
}
237-
238234
public CombinedFieldsQueryBuilder autoGenerateSynonymsPhraseQuery(boolean enable) {
239235
this.autoGenerateSynonymsPhraseQuery = enable;
240236
return this;
241237
}
242238

243-
/**
244-
* Whether phrase queries should be automatically generated for multi terms synonyms.
245-
* Defaults to {@code true}.
246-
*/
247-
public boolean autoGenerateSynonymsPhraseQuery() {
248-
return autoGenerateSynonymsPhraseQuery;
249-
}
250-
251239
private static void validateFieldBoost(float boost) {
252240
if (boost < 1.0f) {
253241
throw new IllegalArgumentException("[" + NAME + "] requires field boosts to be >= 1.0");

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,4 @@ public String getTierPreference() {
154154
return tier.isEmpty() == false ? tier : null;
155155
}
156156

157-
/**
158-
* We're holding on to the index tier in the context as otherwise we'd need
159-
* to re-parse it from the index settings when evaluating the _tier field.
160-
*/
161-
public String tier() {
162-
return tier;
163-
}
164157
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public String fieldName() {
6868
}
6969

7070
@Override
71-
protected QueryBuilder doIndexMetadataRewrite(QueryRewriteContext context) throws IOException {
71+
protected QueryBuilder doIndexMetadataRewrite(QueryRewriteContext context) {
7272
if (getMappedFields(context, fieldName).isEmpty()) {
7373
return new MatchNoneQueryBuilder("The \"" + getName() + "\" query was rewritten to a \"match_none\" query.");
7474
} else {

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

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -78,56 +78,6 @@ public FuzzyQueryBuilder(String fieldName, String value) {
7878
this(fieldName, (Object) value);
7979
}
8080

81-
/**
82-
* Constructs a new fuzzy query.
83-
*
84-
* @param fieldName The name of the field
85-
* @param value The value of the text
86-
*/
87-
public FuzzyQueryBuilder(String fieldName, int value) {
88-
this(fieldName, (Object) value);
89-
}
90-
91-
/**
92-
* Constructs a new fuzzy query.
93-
*
94-
* @param fieldName The name of the field
95-
* @param value The value of the text
96-
*/
97-
public FuzzyQueryBuilder(String fieldName, long value) {
98-
this(fieldName, (Object) value);
99-
}
100-
101-
/**
102-
* Constructs a new fuzzy query.
103-
*
104-
* @param fieldName The name of the field
105-
* @param value The value of the text
106-
*/
107-
public FuzzyQueryBuilder(String fieldName, float value) {
108-
this(fieldName, (Object) value);
109-
}
110-
111-
/**
112-
* Constructs a new fuzzy query.
113-
*
114-
* @param fieldName The name of the field
115-
* @param value The value of the text
116-
*/
117-
public FuzzyQueryBuilder(String fieldName, double value) {
118-
this(fieldName, (Object) value);
119-
}
120-
121-
/**
122-
* Constructs a new fuzzy query.
123-
*
124-
* @param fieldName The name of the field
125-
* @param value The value of the text
126-
*/
127-
public FuzzyQueryBuilder(String fieldName, boolean value) {
128-
this(fieldName, (Object) value);
129-
}
130-
13181
/**
13282
* Constructs a new fuzzy query.
13383
*
@@ -193,19 +143,11 @@ public FuzzyQueryBuilder prefixLength(int prefixLength) {
193143
return this;
194144
}
195145

196-
public int prefixLength() {
197-
return this.prefixLength;
198-
}
199-
200146
public FuzzyQueryBuilder maxExpansions(int maxExpansions) {
201147
this.maxExpansions = maxExpansions;
202148
return this;
203149
}
204150

205-
public int maxExpansions() {
206-
return this.maxExpansions;
207-
}
208-
209151
public FuzzyQueryBuilder transpositions(boolean transpositions) {
210152
this.transpositions = transpositions;
211153
return this;
@@ -220,10 +162,6 @@ public FuzzyQueryBuilder rewrite(String rewrite) {
220162
return this;
221163
}
222164

223-
public String rewrite() {
224-
return this.rewrite;
225-
}
226-
227165
@Override
228166
protected void doXContent(XContentBuilder builder, Params params) throws IOException {
229167
builder.startObject(NAME);

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

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.elasticsearch.common.geo.SpatialStrategy;
2424
import org.elasticsearch.common.io.stream.StreamInput;
2525
import org.elasticsearch.common.io.stream.StreamOutput;
26-
import org.elasticsearch.common.logging.DeprecationLogger;
2726
import org.elasticsearch.geometry.Rectangle;
2827
import org.elasticsearch.geometry.utils.Geohash;
2928
import org.elasticsearch.index.mapper.GeoShapeQueryable;
@@ -45,10 +44,6 @@
4544
public class GeoBoundingBoxQueryBuilder extends AbstractQueryBuilder<GeoBoundingBoxQueryBuilder> {
4645
public static final String NAME = "geo_bounding_box";
4746

48-
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(GeoBoundingBoxQueryBuilder.class);
49-
50-
private static final String TYPE_PARAMETER_DEPRECATION_MESSAGE = "Deprecated parameter [type] used, it should no longer be specified.";
51-
5247
/**
5348
* The default value for ignore_unmapped.
5449
*/
@@ -204,13 +199,6 @@ public GeoBoundingBoxQueryBuilder setValidationMethod(GeoValidationMethod method
204199
return this;
205200
}
206201

207-
/**
208-
* Returns geo coordinate validation method to use.
209-
* */
210-
public GeoValidationMethod getValidationMethod() {
211-
return this.validationMethod;
212-
}
213-
214202
/** Returns the name of the field to base the bounding box computation on. */
215203
public String fieldName() {
216204
return this.fieldName;
@@ -226,15 +214,6 @@ public GeoBoundingBoxQueryBuilder ignoreUnmapped(boolean ignoreUnmapped) {
226214
return this;
227215
}
228216

229-
/**
230-
* Gets whether the query builder will ignore unmapped fields (and run a
231-
* {@link MatchNoDocsQuery} in place of this query) or throw an exception if
232-
* the field is unmapped.
233-
*/
234-
public boolean ignoreUnmapped() {
235-
return ignoreUnmapped;
236-
}
237-
238217
QueryValidationException checkLatLon() {
239218
if (GeoValidationMethod.isIgnoreMalformed(validationMethod)) {
240219
return null;

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

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -183,21 +183,11 @@ public GeoDistanceQueryBuilder geoDistance(GeoDistance geoDistance) {
183183
return this;
184184
}
185185

186-
/** Returns geo distance calculation type to use. */
187-
public GeoDistance geoDistance() {
188-
return this.geoDistance;
189-
}
190-
191186
/** Set validation method for geo coordinates. */
192187
public void setValidationMethod(GeoValidationMethod method) {
193188
this.validationMethod = method;
194189
}
195190

196-
/** Returns validation method for geo coordinates. */
197-
public GeoValidationMethod getValidationMethod() {
198-
return this.validationMethod;
199-
}
200-
201191
/**
202192
* Sets whether the query builder should ignore unmapped fields (and run a
203193
* {@link MatchNoDocsQuery} in place of this query) or throw an exception if
@@ -208,15 +198,6 @@ public GeoDistanceQueryBuilder ignoreUnmapped(boolean ignoreUnmapped) {
208198
return this;
209199
}
210200

211-
/**
212-
* Gets whether the query builder will ignore unmapped fields (and run a
213-
* {@link MatchNoDocsQuery} in place of this query) or throw an exception if
214-
* the field is unmapped.
215-
*/
216-
public boolean ignoreUnmapped() {
217-
return ignoreUnmapped;
218-
}
219-
220201
@Override
221202
protected Query doToQuery(SearchExecutionContext context) throws IOException {
222203
MappedFieldType fieldType = context.getFieldType(fieldName);

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,6 @@ public GeoPolygonQueryBuilder setValidationMethod(GeoValidationMethod method) {
126126
return this;
127127
}
128128

129-
/** Returns the validation method to use for geo coordinates. */
130-
public GeoValidationMethod getValidationMethod() {
131-
return this.validationMethod;
132-
}
133-
134129
/**
135130
* Sets whether the query builder should ignore unmapped fields (and run a
136131
* {@link MatchNoDocsQuery} in place of this query) or throw an exception if
@@ -141,15 +136,6 @@ public GeoPolygonQueryBuilder ignoreUnmapped(boolean ignoreUnmapped) {
141136
return this;
142137
}
143138

144-
/**
145-
* Gets whether the query builder will ignore unmapped fields (and run a
146-
* {@link MatchNoDocsQuery} in place of this query) or throw an exception if
147-
* the field is unmapped.
148-
*/
149-
public boolean ignoreUnmapped() {
150-
return ignoreUnmapped;
151-
}
152-
153139
@Override
154140
protected Query doToQuery(SearchExecutionContext context) throws IOException {
155141
MappedFieldType fieldType = context.getFieldType(fieldName);

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import org.apache.lucene.search.Query;
1414
import org.elasticsearch.TransportVersion;
1515
import org.elasticsearch.TransportVersions;
16-
import org.elasticsearch.common.ParsingException;
1716
import org.elasticsearch.common.geo.GeometryParser;
1817
import org.elasticsearch.common.geo.ShapeRelation;
1918
import org.elasticsearch.common.geo.SpatialStrategy;
@@ -132,7 +131,7 @@ public GeoShapeQueryBuilder relation(ShapeRelation relation) {
132131
* @return this
133132
*/
134133
public GeoShapeQueryBuilder strategy(SpatialStrategy strategy) {
135-
if (strategy != null && strategy == SpatialStrategy.TERM && relation != ShapeRelation.INTERSECTS) {
134+
if (strategy == SpatialStrategy.TERM && relation != ShapeRelation.INTERSECTS) {
136135
throw new IllegalArgumentException(
137136
"strategy ["
138137
+ strategy.getStrategyName()
@@ -217,11 +216,7 @@ protected boolean parseXContentField(XContentParser parser) throws IOException {
217216
} else if (STRATEGY_FIELD.match(parser.currentName(), parser.getDeprecationHandler())) {
218217
String strategyName = parser.text();
219218
strategy = SpatialStrategy.fromString(strategyName);
220-
if (strategy == null) {
221-
throw new ParsingException(parser.getTokenLocation(), "Unknown strategy [" + strategyName + " ]");
222-
} else {
223-
this.strategy = strategy;
224-
}
219+
this.strategy = strategy;
225220
return true;
226221
}
227222
return false;

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,4 @@ public static boolean isCoerce(GeoValidationMethod method) {
6262
return method == GeoValidationMethod.COERCE;
6363
}
6464

65-
/** Returns validation method corresponding to given coerce and ignoreMalformed values. */
66-
public static GeoValidationMethod infer(boolean coerce, boolean ignoreMalformed) {
67-
if (coerce) {
68-
return GeoValidationMethod.COERCE;
69-
} else if (ignoreMalformed) {
70-
return GeoValidationMethod.IGNORE_MALFORMED;
71-
} else {
72-
return GeoValidationMethod.STRICT;
73-
}
74-
}
75-
7665
}

0 commit comments

Comments
 (0)