Skip to content

Commit

Permalink
addressing comment
Browse files Browse the repository at this point in the history
Signed-off-by: bharath-techie <[email protected]>
  • Loading branch information
bharath-techie committed Nov 19, 2024
1 parent 2d5d391 commit ab950b2
Showing 1 changed file with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@
import org.opensearch.index.compositeindex.datacube.startree.builder.StarTreesBuilder;
import org.opensearch.index.compositeindex.datacube.startree.index.CompositeIndexValues;
import org.opensearch.index.compositeindex.datacube.startree.index.StarTreeValues;
import org.opensearch.index.fielddata.IndexNumericFieldData;
import org.opensearch.index.fielddata.plain.SortedSetOrdinalsIndexFieldData;
import org.opensearch.index.mapper.CompositeMappedFieldType;
import org.opensearch.index.mapper.DocCountFieldMapper;
import org.opensearch.index.mapper.IpFieldMapper;
import org.opensearch.index.mapper.KeywordFieldMapper;
import org.opensearch.index.mapper.MappedFieldType;
import org.opensearch.index.mapper.MapperService;

import java.io.IOException;
Expand Down Expand Up @@ -263,23 +264,38 @@ public SortedSetDocValues getSortedSet(FieldInfo field) {
return DocValues.emptySortedSet();
}
});
}
// TODO : change this logic to evaluate for sortedNumericField specifically
else {
} else if (isSortedNumericField(compositeField)) {
fieldProducerMap.put(compositeField, new EmptyDocValuesProducer() {
@Override
public SortedNumericDocValues getSortedNumeric(FieldInfo field) {
return DocValues.emptySortedNumeric();
}
});
} else {
throw new IllegalStateException(
String.format("Unsupported DocValues field associated with the composite field : %s", compositeField)
);
}
}
compositeFieldSet.remove(compositeField);
}

private boolean isSortedSetField(String field) {
return mapperService.fieldType(field) instanceof KeywordFieldMapper.KeywordFieldType
|| mapperService.fieldType(field) instanceof IpFieldMapper.IpFieldType;
MappedFieldType ft = mapperService.fieldType(field);
assert ft.isAggregatable();
return ft.fielddataBuilder(
"",
() -> { throw new UnsupportedOperationException("SearchLookup not available"); }
) instanceof SortedSetOrdinalsIndexFieldData;
}

private boolean isSortedNumericField(String field) {
MappedFieldType ft = mapperService.fieldType(field);
assert ft.isAggregatable();
return ft.fielddataBuilder(
"",
() -> { throw new UnsupportedOperationException("SearchLookup not available"); }
) instanceof IndexNumericFieldData;
}

@Override
Expand Down Expand Up @@ -372,5 +388,4 @@ private static SegmentWriteState getSegmentWriteState(SegmentWriteState segmentW
segmentWriteState.segmentSuffix
);
}

}

0 comments on commit ab950b2

Please sign in to comment.