We're updating the issue view to help you get more done. 

Report incomplete metadata issues during Elasticsearch mapping generation

Description

Issue spotted here: https://github.com/hibernate/hibernate-search/pull/1217/commits/dfc7f199358808397d144d79d89f7915851db222#r87074164

Right now, we're only logging debug messages when failing to add a property/field to the ES mapping:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 // normal document fields for ( DocumentFieldMetadata fieldMetadata : typeMetadata.getNonEmbeddedDocumentFieldMetadata() ) { try { addPropertyMapping( mappingBuilder, fieldMetadata ); } catch (IncompleteDataException e) { LOG.debug( "Not adding a mapping for field " + fieldMetadata.getAbsoluteName() + " because of incomplete data", e ); } } // bridge-defined fields for ( BridgeDefinedField bridgeDefinedField : getNonEmbeddedBridgeDefinedFields( typeMetadata ) ) { try { addPropertyMapping( mappingBuilder, bridgeDefinedField ); } catch (IncompleteDataException e) { LOG.debug( "Not adding a mapping for field " + bridgeDefinedField.getAbsoluteName() + " because of incomplete data", e ); } } .... for ( FacetMetadata facetMetadata : fieldMetadata.getFacetMetadata() ) { try { addFieldMapping( propertyMapping, mappingBuilder, facetMetadata ); } catch (IncompleteDataException e) { LOG.debug( "Not adding a mapping for facet " + facetMetadata.getAbsoluteName() + " because of incomplete data", e ); } }

The only way to get IncompleteDataException can be found in addTypeOptions:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ... break; case UNKNOWN_NUMERIC: // Likely a custom field bridge which does not expose the type of the given field; either correctly // so (because the given name is the default field and this bridge does not wish to use that field // name as is) or incorrectly; The field will not be added to the mapping, causing an exception at // runtime if the bridge writes that field nevertheless elasticsearchType = null; break; case STRING: case UNKNOWN: default: elasticsearchType = DataType.STRING; break; } if ( elasticsearchType == null ) { throw new IncompleteDataException( "Field type could not be determined" ); }

While I understand that we might not want to make the mapping generation fail completely (so that users may test more easily), at least we should issue a warning. Or maybe even log an error.

Something to be considered: expressed concerned about issuing warnings, since in some enterprises they are considered blocking when putting applications in production.

I feel like one of the purposes of warnings is to inform users about potential error, and leave it to the user to decide if it's bad or not. So in this case, it would be exactly what we need. Now, if it's blocking for some users...

, , WDYT?

Environment

None

Status

Assignee

Yoann Rodière

Reporter

Yoann Rodière

Components

Fix versions

Affects versions

5.6.0.Beta3

Priority

Minor