Skip to content

Commit

Permalink
expose method to indicate whether a field should be fetched via wildc…
Browse files Browse the repository at this point in the history
…ard pattern
  • Loading branch information
javanna committed Apr 4, 2024
1 parent 7b25421 commit 1bb82ed
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ public Query existsQuery(SearchExecutionContext context) {
public ValueFetcher valueFetcher(SearchExecutionContext context, String format) {
throw new UnsupportedOperationException();
}

@Override
public boolean isFetchedViaWildcardExpression() {
return false;
}
}

private static DataStreamTimestampFieldMapper toType(FieldMapper in) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ protected Object parseSourceValue(Object value) {
}
};
}

@Override
public boolean isFetchedViaWildcardExpression() {
return false;
}
}

private DocCountFieldMapper() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ public Query termQuery(Object value, SearchExecutionContext context) {
);
return super.termQuery(value, context);
}

@Override
public boolean isFetchedViaWildcardExpression() {
return false;
}
}

private final Explicit<Boolean> enabled;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ public StoredFieldsSpec storedFieldsSpec() {
};
}

@Override
public boolean isFetchedViaWildcardExpression() {
return false;
}
}

public IndexFieldMapper() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,13 @@ public boolean fieldHasValue(FieldInfos fieldInfos) {
return fieldInfos.fieldInfo(name()) != null;
}

/**
* Whether the field needs to be fetched when a wildcard expression is provided via `stored_fields` option
*/
public boolean isFetchedViaWildcardExpression() {
return true;
}

/**
* Returns a loader for ESQL or {@code null} if the field doesn't support
* ESQL.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ public ValueFetcher valueFetcher(SearchExecutionContext context, String format)
throw new UnsupportedOperationException("Cannot fetch values for internal field [" + name() + "].");
}

@Override
public boolean isFetchedViaWildcardExpression() {
return false;
}

@Override
public boolean mayExistInIndex(SearchExecutionContext context) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ public ValueFetcher valueFetcher(SearchExecutionContext context, String format)
throw new UnsupportedOperationException("Cannot fetch values for internal field [" + name() + "].");
}

@Override
public boolean isFetchedViaWildcardExpression() {
return false;
}

@Override
public Query termQuery(Object value, @Nullable SearchExecutionContext context) {
long v = parse(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public ValueFetcher valueFetcher(SearchExecutionContext context, String format)
return new DocValueFetcher(docValueFormat(format, null), context.getForField(this, FielddataOperation.SEARCH));
}

@Override
public boolean isFetchedViaWildcardExpression() {
return false;
}

@Override
public BlockLoader blockLoader(BlockLoaderContext blContext) {
return new BlockDocValuesReader.LongsBlockLoader(name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,12 @@ public FetchSubPhaseProcessor getProcessor(FetchContext fetchContext) {
Collection<String> fieldNames = sec.getMatchingFieldNames(field);
for (String fieldName : fieldNames) {
MappedFieldType ft = sec.getFieldType(fieldName);
boolean isMetadataField = sec.isMetadataField(fieldName);
assert isMetadataField == false || (ft.isStored() == ft.isFetchedViaWildcardExpression()) : fieldName;
if (ft.isStored() == false) {
continue;
}
storedFields.add(new StoredField(fieldName, ft, sec.isMetadataField(ft.name())));
storedFields.add(new StoredField(fieldName, ft, isMetadataField));
fieldsToLoad.add(ft.name());
}
}
Expand Down

0 comments on commit 1bb82ed

Please sign in to comment.