无法找到具有自定义 FieldBridge 实现的字段

Unable to find field with custom FieldBridge implementation

我似乎无法让最基本的 FieldBridge 实现正常工作。看起来索引过程完全忽略了 @FieldBridge 注释。

实现如下:

public class LocalisedInformationBridge implements FieldBridge {

    @Override
    public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {

        luceneOptions.addFieldToDocument(name + ".test", "test", document);

    }   
}

带有 @FieldBridge 注释的实体:

@OneToMany(mappedBy = "product")
@MapKey(name = "languageCode")
@IndexedEmbedded
@FieldBridge(impl = LocalisedInformationBridge.class)
private Map<String, LocalisedProductInformation> localisedProductInformation;

包含的实体:

@ManyToOne
@JoinColumn(name="productId")
@ContainedIn
private Product product;

当我尝试搜索 localisedProductInformation.test 字段时,出现异常:

org.hibernate.search.exception.SearchException: Unable to find field localisedProductInformation.test

这是我索引数据的方式:

FullTextEntityManager fullTextEntityManager =
        Search.getFullTextEntityManager(entityManager);
fullTextEntityManager.createIndexer().startAndWait();

奇怪的是,当我在 LocalisedInformationBridge class 的 set 方法上设置断点时,调试器不会停止程序的执行。我在这里遗漏了什么非常明显的东西吗?

需要知道的一件事是,当您在容器 属性(数组、集合或映射)上使用 @IndexedEmbedded 时,@Field 注释中定义的任何字段桥都将应用于此 属性的值。 因此,在您的情况下,字段桥将应用于地图的值,而不是地图本身。如果您的地图是空的,则根本不会应用场桥。这是你的情况吗?

这种行为确实有点奇怪(考虑到 @IndexedEmbedded 的目的略有不同),但它已经在一段时间前引入,修复它会导致依赖它的用户回归。因此,在发布新的主要版本之前,这种情况可能会保持下去...