Skip to content

Commit

Permalink
HSEARCH-2470 Made sure overriding the default field type in MetadataP…
Browse files Browse the repository at this point in the history
…rovidingFieldBridge works with projections.

Follow-up on 3278599, which was
incomplete.

Projections used to work in existing tests, but only because we
leveraged the "one-way field bridge" projections. Those are not
supported anymore, thus
org.hibernate.search.elasticsearch.test.ElasticsearchClassBridgeIT.testProjectionOfClassBridgeField()
started failing. Turning AgeBridge into a MetadataProvidingFieldBridge
and overriding the field type didn't work, though, and this commit aims
at fixing just that.
  • Loading branch information
yrodiere authored and Sanne committed Nov 28, 2016
1 parent b22b894 commit b6eca9a
Showing 1 changed file with 6 additions and 0 deletions.
Expand Up @@ -131,6 +131,12 @@ private static ExtendedFieldType toExtendedFieldType(NumericEncodingType numeric
}

public static ExtendedFieldType getType(DocumentFieldMetadata fieldMetadata) {
// Always use user-provided type in priority
BridgeDefinedField overriddenField = fieldMetadata.getBridgeDefinedFields().get( fieldMetadata.getAbsoluteName() );
if ( overriddenField != null ) {
return getType( overriddenField );
}

PropertyMetadata propertyMetata = fieldMetadata.getSourceProperty();
Class<?> propertyClass = propertyMetata == null ? null : propertyMetata.getPropertyClass();
if ( propertyClass == null ) {
Expand Down

0 comments on commit b6eca9a

Please sign in to comment.