Transient attribute that is not derived in HS6

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

First, a warning: if you don’t store this value in the database, upon mass indexing, Hibernate Search won’t be able to retrieve it, and thus it will be lost.

If you ever need to rebuild the index (for example because your mapping changed, or because you’re upgrading to a new, incompatible version of Elasticsearch or Lucene), this data will be missing in your new index.

If that’s fine with you, just use ReindexOnUpdate.NO:

@IndexingDependency(reindexOnUpdate=ReindexOnUpdate.NO)

See this section of the documentation.

Thanks a lot for your detailed reply. This should work for me :slight_smile: