I am using Hibernate Search 5.11 but the search results do not seem to return newly-created entities.
My objects are:
@Indexed
public class objectA {
@Id
@Column(name = "id", nullable = false, precision = 18)
@Field(name = "pkid_sort", bridge = @FieldBridge(impl = BigIntegerNumericFieldBridge.class))
@Field(name = "pkid")
private BigInteger id;
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "objectBid", nullable = false)
**@IndexedEmbedded**
private objectB objectB;
}
@Indexed
public class objectB {
@Id
@Column(name = "id", nullable = false, precision = 18)
@Field(name = "pkid_sort", bridge = @FieldBridge(impl = BigIntegerNumericFieldBridge.class))
@Field(name = "pkid")
private BigInteger id;
@Column(name = "code", length = 20)
@Field
@SortableField
private String code;
}
Update the objectA with crud repository
JSON of objectA
{
"id": null,
"objectB": {
"id": 1234,
"code": test
}
}
objectB already exists in db.
objectARepository.save(objectA);
after i am trying to search the new created objectA with the below code:
Query query = qb.keyword().onField("objectB.code").matching("test").createQuery();
final FullTextQuery fullTextQuery = fullTextEntityManager.createFullTextQuery(query , ObjectA.class);
fullTextQuery.getResultList();
and it s not working, always return empty list.
It works only, searching with primary key id
Query query = qb.keyword().onField("objectB.pkid").matching(1234).createQuery();
final FullTextQuery fullTextQuery = fullTextEntityManager.createFullTextQuery(query , ObjectA.class);
fullTextQuery.getResultList();
With massindexer for this class all works fine but i would like to be able to search objectA with all properties of objectB during the save(update).
Thank you!