Hi all!
I have used Hibernate for quite a while, and now I just started adding Hibernate Search 6.1.7.Final functionality on my Hibernate 5.6.8.Final application. The backend is OpenSearch 1.2.4 running locally in Docker in HTTP mode (not HTTPS)
I got the following error that I can’t seem to find on Google or in this forum anywhere
HSEARCH000058: Exception occurred org.hibernate.search.util.common.SearchException: HSEARCH700088: Invalid indexing request: the add and update operations require a non-null entity.
Failing operation:
Indexing instance of entity 'Item' during mass indexing
org.hibernate.search.util.common.SearchException: HSEARCH700088: Invalid indexing request: the add and update operations require a non-null entity.
at org.hibernate.search.mapper.pojo.work.impl.PojoIndexerImpl.add(PojoIndexerImpl.java:44)
at org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingEntityLoadingRunnable$IndexingBatch.startIndexing(PojoMassIndexingEntityLoadingRunnable.java:208)
at org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingEntityLoadingRunnable$IndexingBatch.startIndexingList(PojoMassIndexingEntityLoadingRunnable.java:155)
at org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingEntityLoadingRunnable$LoadingContext$1.accept(PojoMassIndexingEntityLoadingRunnable.java:125)
at org.hibernate.search.mapper.orm.loading.impl.HibernateOrmMassEntityLoader.load(HibernateOrmMassEntityLoader.java:49)
at org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingEntityLoadingRunnable.runWithFailureHandler(PojoMassIndexingEntityLoadingRunnable.java:60)
at org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingFailureHandledRunnable.run(PojoMassIndexingFailureHandledRunnable.java:32)
at org.hibernate.search.util.common.impl.CancellableExecutionCompletableFuture$CompletingRunnable.run(CancellableExecutionCompletableFuture.java:70)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Suppressed: org.hibernate.search.util.common.AssertionFailure: Processing a non-indexed type in the MassIndexer: null -- this may indicate a bug or a missing test in Hibernate Search. Please report it: https://hibernate.org/community/
at org.hibernate.search.mapper.pojo.massindexing.impl.PojoMassIndexingIndexedTypeGroup.lambda$extractReference$0(PojoMassIndexingIndexedTypeGroup.java:119)
And here I am… reporting to the community
Configuration
Here’s my configuration file application-local.properties
spring.jpa.properties.hibernate.search.backend.hosts=localhost:9200
spring.jpa.properties.hibernate.search.backend.protocol=http
spring.jpa.properties.hibernate.search.backend.username=admin
spring.jpa.properties.hibernate.search.backend.password=admin
MassIndexer
I have also added a MassIndex.java to mass-index the existing DB
@RequiredArgsConstructor
@Slf4j
@Component
public class MassIndex {
private final EntityManager em;
@EventListener(ContextRefreshedEvent.class)
@Transactional(readOnly = true)
public void massIndex() {
try {
var searchSession = Search.session(em);
var indexer = searchSession.massIndexer(Item.class);
indexer.startAndWait();
} catch (Exception exception) {
log.error("INDEXING FAIL ", exception);
}
}
}
#Entity
The entity Item being indexed is as follows
@Entity
@Table(name = "item")
@Getter
@Setter
@Indexed
public class Item {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ITEM_SEQ")
@SequenceGenerator(sequenceName = "_item_id_seq", allocationSize = 1, name = "ITEM_SEQ")
@ToString.Include
private Long id;
@FullTextField
@Column(name = "name", length = 100)
private String name;
There are other fields, but I only annotated name for hibernate search. Note that all Items have a non-null name