See the Elasticsearch documentation: multi-fields The idea is to define additional fields that take the same input as other fields, but transform/store it differently. We could use a "source" or "derivedFrom" or "subFieldOf" attribute on @XXXField annotation:
@FullTextField(name = “myField”, bridge = …)
@KeywordField(subFieldOf = "myField", name = "sort", sortable = Sortable.YES, normalizer = "sortNormalizer")
Note that we would have to forbid the definition of a bridge on such field, because the copy happens automatically in the backend. The backend APIs could expose something like this:
schemaElement.field( "myField", f -> f.asLocalDate().toIndexFieldType() )
.subField( "sort", f -> f.asLocalDate().sortable( Sortable.YES ).normalizer( "sortNormalizer" ).toIndexFieldType() )
.createAccessor();
Or maybe a better API could be designed while we address HSEARCH-3444 Open . Original discussion: https://docs.google.com/document/d/16PAa__LsxyLZcbW3q1MvgyIznh4ZnCYLupbNMXKMRds/edit#heading=h.gxh9craiaqrn |