Consider using the fields feature of Elasticsearch for properties mapped on several fields

Description

Today we map each field in a Elasticsearch document field. If the bridge is the same, that means we copy the same data twice unnecessarily in the Elasticsearch document.

Elasticsearch has the option to define multiple mappings for a given document attribute via the "fields" feature
https://www.elastic.co/guide/en/elasticsearch/reference/2.3/multi-fields.html

The drawback is that it cannot be done for different fieldbridges as the output might be different.
Also it does not necessarily align with our naming conventions: they use nested properties for additional fields e.g. title and title.raw where we tend to do title and title_raw

My gut feeling is that it's a lot of twists for a minor alignment and it should not be implemented.

Environment

None

Activity

Show:
Sanne Grinovero
April 12, 2016, 11:36 PM

My gut feeling is that it's a lot of twists for a minor alignment and it should not be implemented.

Same here, but scheduling for 5.6 to not forget trying this.

Yoann Rodière
November 14, 2016, 10:20 AM

Another issue with this is that we're not currently using the entity property path in Elasticsearch, but rather the field path (which may be different when using things like @IndexedEmbedded.prefix, @Field.name, or simply custom field bridges). So adding support for fields would mean removing support for features such as @IndexedEmbedded.prefix, for instance.

Also, we'd probably have an issue with such a mapping:

What would be the name of the property in the Elasticsearch mapping? We don't have a clear candidate for that, since the default name is not attributed to any field, and we wouldn't know which ES datatype to use for this default name anyway.

Side-note: fields are being used right now in a very specific context: faceting. See https://github.com/hibernate/hibernate-search/pull/1217 ().

Bottom line: in my opinion, there's more to this ticket than just slightly tweaking the way we map Hibernate Search fields to Elasticsearch properties/fields. It's a more of a deep change in our internal representation of a document and field tree.

Anyway... To me, it's Hibernate Search 6.0 material, since adding such feature would probably require definitely removing support for some features in Elasticsearch (@IndexedEmbedded.prefix in particular).
Ok to move this to 6.0?

Yoann Rodière
March 28, 2019, 3:46 PM

Closing and continuing the discussion on HSEARCH-3465.

Assignee

Unassigned

Reporter

Emmanuel Bernard

Labels

None

Suitable for new contributors

None

Pull Request

None

Feedback Requested

None

Components

Affects versions

Priority

Major
Configure