Skip to content

Commit

Permalink
Revert "Add fieldType to AbstractQueryBuilder and SortBuilder (opense…
Browse files Browse the repository at this point in the history
…arch-project#15328)" (opensearch-project#15633)

This reverts commit 839ba0b.

Signed-off-by: Ankit Jain <[email protected]>
  • Loading branch information
jainankitk authored and akolarkunnu committed Sep 10, 2024
1 parent b9c570d commit 7fbe1e6
Show file tree
Hide file tree
Showing 46 changed files with 6 additions and 379 deletions.
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- [Workload Management] Add rejection logic for co-ordinator and shard level requests ([#15428](https://github.com/opensearch-project/OpenSearch/pull/15428)))
- Adding translog durability validation in index templates ([#15494](https://github.com/opensearch-project/OpenSearch/pull/15494))
- Add index creation using the context field ([#15290](https://github.com/opensearch-project/OpenSearch/pull/15290))
- Add fieldType to AbstractQueryBuilder and FieldSortBuilder ([#15328](https://github.com/opensearch-project/OpenSearch/pull/15328)))
- [Reader Writer Separation] Add searchOnly replica routing configuration ([#15410](https://github.com/opensearch-project/OpenSearch/pull/15410))
- [Range Queries] Add new approximateable query framework to short-circuit range queries ([#13788](https://github.com/opensearch-project/OpenSearch/pull/13788))
- [Workload Management] Add query group level failure tracking ([#15227](https://github.com/opensearch-project/OpenSearch/pull/15527))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.endObject();
}

@Override
public final String fieldName() {
return getDefaultFieldName();
}

@Override
protected Query doToQuery(QueryShardContext context) throws IOException {
final MappedFieldType ft = context.fieldMapper(field);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.endObject();
}

@Override
public final String fieldName() {
return getDefaultFieldName();
}

public static HasChildQueryBuilder fromXContent(XContentParser parser) throws IOException {
float boost = AbstractQueryBuilder.DEFAULT_BOOST;
String childType = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.endObject();
}

@Override
public final String fieldName() {
return getDefaultFieldName();
}

public static HasParentQueryBuilder fromXContent(XContentParser parser) throws IOException {
float boost = AbstractQueryBuilder.DEFAULT_BOOST;
String parentType = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.endObject();
}

@Override
public final String fieldName() {
return getDefaultFieldName();
}

public static ParentIdQueryBuilder fromXContent(XContentParser parser) throws IOException {
float boost = AbstractQueryBuilder.DEFAULT_BOOST;
String type = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.endObject();
}

@Override
public final String fieldName() {
return getDefaultFieldName();
}

private static final ConstructingObjectParser<PercolateQueryBuilder, Void> PARSER = new ConstructingObjectParser<>(NAME, args -> {
String field = (String) args[0];
BytesReference document = (BytesReference) args[1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ class FieldTypeLookup implements Iterable<MappedFieldType> {
}

/**
* Returns the {@link MappedFieldType} for the given field name
* or null if the field name is not found.
* Returns the mapped field type for the given field name.
*/
public MappedFieldType get(String field) {
String concreteField = aliasToConcreteName.getOrDefault(field, field);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -632,8 +632,7 @@ public DocumentMapperForType documentMapperWithAutoCreate() {
}

/**
* Given the full name of a field, returns its {@link MappedFieldType}
* or null if the field is not found.
* Given the full name of a field, returns its {@link MappedFieldType}.
*/
public MappedFieldType fieldType(String fullName) {
return this.mapper == null ? null : this.mapper.fieldTypes().get(fullName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public abstract class AbstractQueryBuilder<QB extends AbstractQueryBuilder<QB>>
public static final ParseField BOOST_FIELD = new ParseField("boost");

protected String queryName;
protected String fieldType;
protected float boost = DEFAULT_BOOST;

protected AbstractQueryBuilder() {
Expand Down Expand Up @@ -113,27 +112,6 @@ protected void printBoostAndQueryName(XContentBuilder builder) throws IOExceptio
}
}

/**
* Returns field name as String.
* Abstract method to be implemented by all child classes.
*/
public abstract String fieldName();

/**
* Default method for child classes which do not have a custom {@link #fieldName()} implementation.
*/
protected static String getDefaultFieldName() {
return null;
};

/**
* Returns field type as String for QueryBuilder classes which have a defined fieldName.
* Else returns null.
*/
public final String getFieldType() {
return fieldType;
};

@Override
public final Query toQuery(QueryShardContext context) throws IOException {
Query query = doToQuery(context);
Expand All @@ -147,7 +125,6 @@ public final Query toQuery(QueryShardContext context) throws IOException {
context.addNamedQuery(queryName, query);
}
}
fieldType = context.getFieldTypeString(fieldName());
return query;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,11 +270,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.endObject();
}

@Override
public final String fieldName() {
return getDefaultFieldName();
}

private static void doXArrayContent(ParseField field, List<QueryBuilder> clauses, XContentBuilder builder, Params params)
throws IOException {
if (clauses.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.endObject();
}

@Override
public final String fieldName() {
return getDefaultFieldName();
}

public static BoostingQueryBuilder fromXContent(XContentParser parser) throws IOException {
QueryBuilder positiveQuery = null;
boolean positiveQueryFound = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.endObject();
}

@Override
public final String fieldName() {
return getDefaultFieldName();
}

public static ConstantScoreQueryBuilder fromXContent(XContentParser parser) throws IOException {
QueryBuilder query = null;
boolean queryFound = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.endObject();
}

@Override
public final String fieldName() {
return getDefaultFieldName();
}

public static DisMaxQueryBuilder fromXContent(XContentParser parser) throws IOException {
float boost = AbstractQueryBuilder.DEFAULT_BOOST;
float tieBreaker = DisMaxQueryBuilder.DEFAULT_TIE_BREAKER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ protected Query doToQuery(QueryShardContext context) throws IOException {
return fieldType.distanceFeatureQuery(origin.origin(), pivot, 1.0f, context);
}

@Override
public String fieldName() {
String fieldName() {
return field;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.endObject();
}

@Override
public final String fieldName() {
return getDefaultFieldName();
}

private static final ObjectParser<IdsQueryBuilder, Void> PARSER = new ObjectParser<>(NAME, IdsQueryBuilder::new);

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.endObject();
}

@Override
public final String fieldName() {
return getDefaultFieldName();
}

public static IntervalQueryBuilder fromXContent(XContentParser parser) throws IOException {
if (parser.nextToken() != XContentParser.Token.FIELD_NAME) {
throw new ParsingException(parser.getTokenLocation(), "Expected [FIELD_NAME] but got [" + parser.currentToken() + "]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.endObject();
}

@Override
public final String fieldName() {
return getDefaultFieldName();
}

private static final ObjectParser<MatchAllQueryBuilder, Void> PARSER = new ObjectParser<>(NAME, MatchAllQueryBuilder::new);

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.endObject();
}

@Override
public final String fieldName() {
return getDefaultFieldName();
}

public static MatchNoneQueryBuilder fromXContent(XContentParser parser) throws IOException {
String currentFieldName = null;
XContentParser.Token token;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -792,11 +792,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.endObject();
}

@Override
public final String fieldName() {
return getDefaultFieldName();
}

public static MoreLikeThisQueryBuilder fromXContent(XContentParser parser) throws IOException {
// document inputs
List<String> fields = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -631,11 +631,6 @@ public void doXContent(XContentBuilder builder, Params params) throws IOExceptio
builder.endObject();
}

@Override
public final String fieldName() {
return getDefaultFieldName();
}

public static MultiMatchQueryBuilder fromXContent(XContentParser parser) throws IOException {
Object value = null;
Map<String, Float> fieldsBoosts = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.endObject();
}

@Override
public final String fieldName() {
return getDefaultFieldName();
}

public static NestedQueryBuilder fromXContent(XContentParser parser) throws IOException {
float boost = AbstractQueryBuilder.DEFAULT_BOOST;
ScoreMode scoreMode = ScoreMode.Avg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,22 +364,6 @@ public MappedFieldType fieldMapper(String name) {
return failIfFieldMappingNotFound(name, mapperService.fieldType(name));
}

/**
* Returns field type as String for the given field name.
* If field is not mapped or mapperService is null, returns null.
*/
public String getFieldTypeString(String fieldName) {
if (fieldName != null) {
if (mapperService != null) {
MappedFieldType mappedFieldType = mapperService.fieldType(fieldName);
if (mappedFieldType != null) {
return mappedFieldType.typeName();
}
}
}
return null;
}

public ObjectMapper getObjectMapper(String name) {
return mapperService.getObjectMapper(name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -647,11 +647,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.endObject();
}

@Override
public final String fieldName() {
return getDefaultFieldName();
}

public static QueryStringQueryBuilder fromXContent(XContentParser parser) throws IOException {
String currentFieldName = null;
XContentParser.Token token;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,6 @@ protected void doXContent(XContentBuilder builder, Params builderParams) throws
builder.endObject();
}

@Override
public final String fieldName() {
return getDefaultFieldName();
}

public static ScriptQueryBuilder fromXContent(XContentParser parser) throws IOException {
// also, when caching, since its isCacheable is false, will result in loading all bit set...
Script script = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,11 +479,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.endObject();
}

@Override
public final String fieldName() {
return getDefaultFieldName();
}

public static SimpleQueryStringBuilder fromXContent(XContentParser parser) throws IOException {
String currentFieldName = null;
String queryBody = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.endObject();
}

@Override
public final String fieldName() {
return getDefaultFieldName();
}

public static SpanContainingQueryBuilder fromXContent(XContentParser parser) throws IOException {
float boost = AbstractQueryBuilder.DEFAULT_BOOST;
String queryName = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.endObject();
}

@Override
public final String fieldName() {
return getDefaultFieldName();
}

public static SpanFirstQueryBuilder fromXContent(XContentParser parser) throws IOException {
float boost = AbstractQueryBuilder.DEFAULT_BOOST;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.endObject();
}

@Override
public final String fieldName() {
return getDefaultFieldName();
}

public static SpanMultiTermQueryBuilder fromXContent(XContentParser parser) throws IOException {
String currentFieldName = null;
MultiTermQueryBuilder subQuery = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.endObject();
}

@Override
public final String fieldName() {
return getDefaultFieldName();
}

public static SpanNearQueryBuilder fromXContent(XContentParser parser) throws IOException {
float boost = AbstractQueryBuilder.DEFAULT_BOOST;
int slop = DEFAULT_SLOP;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,6 @@ protected void doXContent(XContentBuilder builder, Params params) throws IOExcep
builder.endObject();
}

@Override
public final String fieldName() {
return getDefaultFieldName();
}

public static SpanNotQueryBuilder fromXContent(XContentParser parser) throws IOException {
float boost = AbstractQueryBuilder.DEFAULT_BOOST;

Expand Down
Loading

0 comments on commit 7fbe1e6

Please sign in to comment.