Вам необходимо заменить @IndexedEmbedded
на мост.
Определить мост:
public class ProductImageSetPathBridge implements MetadataProvidingFieldBridge {
@Override
public void configureFieldMetadata(String name, FieldMetadataBuilder builder) {
builder.field( name, FieldType.STRING );
}
@Override
public void set(String fieldName, Object value, Document document, LuceneOptions luceneOptions) {
if ( value != null ) {
indexNotNullIterable( fieldName, value, document, luceneOptions );
}
}
private void indexNotNullIterable(String name, Object value, Document document, LuceneOptions luceneOptions) {
Iterable<?> collection = (Iterable<?>) value;
for ( Object entry : collection ) {
indexEntry( name, entry, document, luceneOptions );
}
}
private void indexEntry(String fieldName, Object entry, Document document, LuceneOptions luceneOptions) {
ProductImage image = (ProductImage) entry;
if ( image != null ) {
luceneOptions.addFieldToDocument( fieldName, image.getId().getPath(), document );
}
}
}
И применить его в нужном месте, в классе Product
:
@Entity
@Table(name = "products")
@Indexed(index = "products")
public class Product implements Serializable {
@Id
String gtin;
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumn(name = "gtin", referencedColumnName = "gtin")
// Remove this @IndexedEmbedded
//@IndexedEmbedded
// And put this instead
// Don't forget analyze = Analyze.NO, because you probably don't want an URL to be analyzed
@Field(bridge = @FieldBridge(impl = ProductImageSetPathBridge.class), analyze = Analyze.NO)
Set<ProductImage> images = new TreeSet<>();
}
Дополнительная информация о мостах: