@Entity
@Table(name = "asset")
@Indexed(index = "asset")
@Analyzer(impl = IKAnalyzer.class)
public class Asset {
@Column(name = "asset_name", length = 128, nullable = false)
@Field(name = "asset_name", index = Index.TOKENIZED, store = Store.YES)
private String assetName;
@Column(name = "type", length = 32, nullable = false)
@Enumerated(value = EnumType.STRING)
@Field(name = "type", index = Index.TOKENIZED, store = Store.YES)
private AssetTypeEnum type;
}
这是我的hibernate搜索配置。 AssetTypeEnum是枚举类型。我想索引数据库中现有的数据。这是代码
Session session = sessionFactory.openSession();
FullTextSession fullTextSession = Search.getFullTextSession(session);
Transaction tx = fullTextSession.beginTransaction();
fullTextSession.createIndexer(Asset.class)
.batchSizeToLoadObjects(25)
.cacheMode(CacheMode.IGNORE)
.threadsToLoadObjects(5)
.threadsForSubsequentFetching(20)
.startAndWait();
tx.commit();
session.close();
创建新资产时没有问题,资产可以自动索引。但是我无法使用db中的现有数据的枚举类型进行索引。如果我删除枚举类型,它可以工作。 有人遇到过这个问题吗?谢谢。