我正在尝试使用 Hibernate Search 实现多面搜索,我发现要在您的模态中启用多面搜索,您需要添加 @Field 注释,如下例所示
@Entity
@Indexed(index = "index/books")
public class Book {
private Long id;
private String title;
private String author;
private String category;
private int price;
@Id
@GeneratedValue
public Long getId() {
return id;
}
@Field(name = "title", analyze = Analyze.YES, store = Store.YES)
public String getTitle() {
return title;
}
public void setTitle(final String title) {
this.title = title;
}
public void setId(final Long id) {
this.id = id;
}
public void setAuthor(final String author) {
this.author = author;
}
@Field(analyze = Analyze.NO, store = Store.YES)
public String getAuthor() {
return author;
}
@Field(analyze = Analyze.NO, store = Store.YES)
public String getCategory() {
return category;
}
public void setCategory(final String category) {
this.category = category;
}
@Field(analyze = Analyze.NO, store = Store.YES)
public int getPrice() {
return price;
}
public void setPrice(final int price) {
this.price = price;
}
}
我认为这适用于创建的每条新记录,但我现有的数据呢?有没有办法让我现有的数据用于休眠分面搜索。?