Skip to content

Commit

Permalink
iter
Browse files Browse the repository at this point in the history
  • Loading branch information
javanna committed Apr 3, 2024
1 parent b0bfa65 commit a38f5ce
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public Query existsQuery(SearchExecutionContext context) {

@Override
public ValueFetcher valueFetcher(SearchExecutionContext context, String format) {
return new StoredValueFetcher(context.lookup(), NAME);
throw new UnsupportedOperationException();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public Query existsQuery(SearchExecutionContext context) {

@Override
public ValueFetcher valueFetcher(SearchExecutionContext context, String format) {
return new StoredValueFetcher(context.lookup(), NAME);
throw new UnsupportedOperationException("Cannot fetch values for internal field [" + name() + "].");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public boolean mayExistInIndex(SearchExecutionContext context) {

@Override
public ValueFetcher valueFetcher(SearchExecutionContext context, String format) {
return new StoredValueFetcher(context.lookup(), NAME);
throw new UnsupportedOperationException("Cannot fetch values for internal field [" + name() + "].");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

import org.apache.lucene.index.LeafReaderContext;
import org.elasticsearch.common.document.DocumentField;
import org.elasticsearch.index.mapper.FieldNamesFieldMapper;
import org.elasticsearch.index.mapper.IgnoredFieldMapper;
import org.elasticsearch.index.mapper.LegacyTypeFieldMapper;
import org.elasticsearch.index.mapper.MappedFieldType;
import org.elasticsearch.index.mapper.RoutingFieldMapper;
import org.elasticsearch.index.mapper.SourceFieldMapper;
import org.elasticsearch.index.query.SearchExecutionContext;
Expand Down Expand Up @@ -73,8 +73,12 @@ public FetchSubPhaseProcessor getProcessor(FetchContext fetchContext) {
Collection<String> fieldNames = searchExecutionContext.getMatchingFieldNames(field);
for (String fieldName : fieldNames) {
if (fieldName.equals(SourceFieldMapper.NAME) == false && searchExecutionContext.isMetadataField(fieldName)) {
// TODO only metadata field that's not stored, it should be excluded in some other way?
if (fieldName.equals(FieldNamesFieldMapper.NAME) == false) {
MappedFieldType fieldType = searchExecutionContext.getFieldType(fieldName);
// TODO this is for bw comp with previous behaviour of _stored_fields: there's a bunch of metadata fields that
// are stored and were never exposed to fetch.
// Some are fetchable via doc_values, but they can't be fetched either from fields, hence it makes sense to keep
// this conditional for the time being?
if (fieldType.isStored()) {
fields.add(new FieldAndFormat(fieldName, null));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
import org.elasticsearch.index.mapper.MappedFieldType;
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.mapper.MapperServiceTestCase;
import org.elasticsearch.index.mapper.NestedPathFieldMapper;
import org.elasticsearch.index.mapper.ParsedDocument;
import org.elasticsearch.index.mapper.SeqNoFieldMapper;
import org.elasticsearch.index.mapper.SourceFieldMapper;
import org.elasticsearch.index.query.SearchExecutionContext;
import org.elasticsearch.script.Script;
Expand Down Expand Up @@ -263,10 +261,7 @@ public void testMetadataFields() throws IOException {
});

// several other metadata fields throw exceptions via their value fetchers when trying to get them
for (String fieldname : List.of(
SourceFieldMapper.NAME,
FieldNamesFieldMapper.NAME
)) {
for (String fieldname : List.of(SourceFieldMapper.NAME, FieldNamesFieldMapper.NAME)) {
expectThrows(UnsupportedOperationException.class, () -> fetchFields(mapperService, source, fieldname));
}
}
Expand Down

0 comments on commit a38f5ce

Please sign in to comment.