Hi All,
Can any one please help me, where Case (Parent) , Patent(Child) as below
public class Case extends VersioningEntity {
public class Patent extends Case {
Using both, how to prepare Elastic Search Query using Predicates or any other ways.
When I tried, to write, I am getting only Patent Data . I am not getting Case data.
What have you tried so far? It’s best to include the query you were attempting to execute next time.
To get both Case and Parent they both have to be indexed entities and you should target the Case entity to get both back in the results, e.g.:
I’ve created a simple test with two entities and search results containing both types:
Try searching with a simple predicate like “match all”. Maybe your results are filtered because of the predicate, and that’s why you do not see other entries.
Then, looking at the code you’ve added in the screenshots… it raises a question… initially you mentioned that you are using the Elasticsearch backend (e.g. in the topic title), but then your code examples are using the Lucene extension … so there’s definitely some mismatch here…
Ignore those lucene related code, as we are migrating Hibernate search5 to 7 ,
old code still exist , I will clear it once I am able to get result, with My predicates
Just now we tried as you mentioned you can see the result still we are getting only Patent object in results,
If you have a lot of records, it is OK to get patent entries returned; they may have just scored better than case entities… that was why I was suggesting to try with a few records (2-3) so you are more sure of what’s happening. But if you have to run it against more records, then next, I’d try adding a predicate that you know definitely matches the case entity only and not patent.
If that still doesn’t return the case entity for you, then please create a small reproducer using the test case template I shared earlier hibernate-test-case-templates/search/hibernate-search-7 at main · hibernate/hibernate-test-case-templates · GitHub and we’ll take a look at it.
With your suggestion, I am able to fetch only Id of Case by using @DocumentId to My Id field.
But I want to get List SearchResult of Case insted List of Long
I want to add some more point here ,
I am unable to get Case object , as I tried below code .
List<Case> result = fullTextEntityManager.search(Case.class).where(f ->
f.match().field("fileReference").matching("dscsc")).fetchHits(10);
But Strange that, With the below code ,I am able to get Id of particular entity .
List<Long> result = fullTextEntityManager.search(Case.class) .select( f ->
f.id( Long.class ) ).where( f -> f.match().field(
"title").matching("cccc")).fetchHits(10);
So please help me, why I am not getting Case object or list of Case object .
I’m not entirely sure what you are asking of me here… In the two examples you’ve shared, you have different predicates in the where clause, so it’s ok to get different hits, first one is returning back an entity since you haven’t specified any projection, while the second one uses the projection and returns just an id …
The query you’ve shared seems fine, so not sure what particular problem you’ve encountered. If you want me to look closer at what’s happening, please put together a test case using the template I’ve shared earlier.
I have tried adding in your test template, their it is working fine,
So it’s look me strange behavior in local. this is my primary entity it contain many @IndexedEmbedded and multiple mapped entity exist, it may be the Cause ,
Or I am missing any particular persistnace.xml Configuration missed.