I am using Hibernate Search 6.
I have an entity which contains a string field which I would like to index, but not persist. As such it is marked as @Transient. This is the field in question
@Transient
@FullTextField(name = "myContentText", searchable = Searchable.YES, projectable = Projectable.YES, analyzer = "standardAnalyzer")
@FullTextField(name = "myContentTextEdgeNGram", searchable= Searchable.YES, projectable= Projectable.NO, analyzer = "autocompleteEdgeAnalyzer")
@FullTextField(name = "myContentTextNGram", searchable= Searchable.YES, projectable= Projectable.NO, analyzer = "autocompleteNGramAnalyzer")
@FullTextField(name = "myContentTextPhonetic", searchable= Searchable.YES, projectable= Projectable.NO, analyzer = "autocompletePhoneticAnalyzer")
@OptimisticLock(excluded = true)
private String myContentText;
public void setContentText(String theContent){
myContentText = theContent;
}
public String getContentText() {
return myContentText;
}
I want this field to be reindexed whenever this entity is persisted. Since this field is not derived from anything, I can’t use @IndexingDependency(derivedFrom=)
method. I have tried adding
@IndexingDependency(reindexOnUpdate=ReindexOnUpdate.SHALLOW)
expecting this to cause a reindex whenever the relevant setter is called, but it is throwing this bootstrap error:
Context: Hibernate ORM mapping, type 'ca.xxx.yyy.jpa.model.entity.MyEntity'
Failure:
org.hibernate.search.util.common.SearchException: HSEARCH800007: Unable to resolve path '.myContentText' to a persisted attribute in Hibernate ORM metadata. If this path points to a transient attribute, use @IndexingDependency(derivedFrom = ...) to specify which persisted attributes it is derived from. See the reference documentation for more information.
at org.hibernate.search.mapper.orm.model.impl.HibernateOrmPathFilterFactory.resolvePropertyNode(HibernateOrmPathFilterFactory.java:353)
Is there some way to accomplish what I’m after here? It is essentially a desire to index a field which is not persisted