I have two entities: Action
and User
with many-to-one relationship.
I search for actions and I'd like to have a user full name
facet, but instead of a full_name
column in the database, I have first_name
and last_name
.
Is there any way to create a combined facet in hibernate search that would use firstName
and lastName
together? Or is there a way to create a combined field fullName
that will exist in the search index (with a facet) but not in the database?
The mapping is the following:
@Entity
public class Action {
...
@IndexEmbedded
private User user;
}
@Entity
public class User {
...
@Facet
@Field(analyze = Analyze.NO)
private String firstName;
@Facet
@Field(analyze = Analyze.NO)
private String lastName;
}
You can use @Facet and @Field on a method of your User object.
So you can define something like:
@Facet
@Field
public String getFullName() {
return new StringJoiner(" ").add(firstName).add(lastName).toString();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.