Boolean fields in embedded collections are not indexed properly when using Elasticsearch

Description

Boolean fields in embedded collections are not indexed properly when using Elasticsearch. When the Lucene document gets converted to JSON all the elements in the collection end up having the same value, that of the first element, regardless of the actual values.
The PUT request to Elasticsearch can then contain wrong data and thus Elasticsearch ends up containing wrong data in the index.

The problem seems to be in org.hibernate.search.elasticsearch.impl.ElasticsearchIndexWorkVisitor.convertFieldToJson(JsonObject, JsonAccessorBuilder, EntityIndexBinding, NestingMarker, Document, IndexableField):323, there we retrieve the value of the field from the Lucene document without taking into account the index of the item in the collection, thus always retrieving the first value.

Environment

None

Status

Assignee

Yoann Rodière

Reporter

Miguel Diogo

Labels

None

Suitable for new contributors

None

Feedback Requested

None

Components

Fix versions

Affects versions

5.9.3.Final
5.10.4.Final

Priority

Major
Configure