Skip to content

Commit

Permalink
Add fieldType to Abstract Query Builder
Browse files Browse the repository at this point in the history
Signed-off-by: David Zane <[email protected]>
  • Loading branch information
dzane17 committed Aug 21, 2024
1 parent 13163ab commit 095565f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ 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 @@ -112,6 +113,14 @@ protected void printBoostAndQueryName(XContentBuilder builder) throws IOExceptio
}
}

public String fieldName() {
return "none";
};

public final String getFieldType() {
return fieldType;
};

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ protected Query doToQuery(QueryShardContext context) throws IOException {
return fieldType.distanceFeatureQuery(origin.origin(), pivot, 1.0f, context);
}

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

Expand Down

0 comments on commit 095565f

Please sign in to comment.