Hi there,
I am using Hibernate 3.6.10 with Hibernate Search 3.4.2.Final.
Imagine the illustrative example where we have two classes:
Code:
@Entity
@Indexed
public class Employee
{
private String bio;
@Field(name = "bio")
public String getBio(){
return bio;
}
}
Code:
@Entity
@Indexed
public class Car
{
private String description;
@Field(name = "description")
public String getDescription(){
return description;
}
}
Suppose that the two above classes have many more fields that we search on.
Assume we have an Employee record with bio "Employee's short bio" and a Car record with description "Car's short description" in our persistent storage and I perform a search query on the keyword "short" on both the Employee and the Car index.
I want to present the search results to the user in the form:
Employee matched with
bio: "Employee's short bio"
Car matched with
description: "Car's short description"
For this I need to know the names of the fields that matched, i.e. bio and decription in this case.
Is there any smart way of getting this information?
Certainly, it's possible to just manually check all fields, but I would prefer a nicer solution if there is one. Also, I've heard it's possible to do it through the Explanation object from Lucene, but this is apparently computationally expensive and therefore not feasible in my application.
Any help will be much appreciated.
Thanks,
goch