假设我有一个如下所示的域对象:
@Entity
@Indexed
public class Thingie implements DomainObject {
private Long id;
private Integer version;
private String title;
private List<String> keywords = new Vector<String>();
@Id
@GeneratedValue
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@Version
public Integer getVersion() {
return version;
}
public void setVersion(Integer version) {
this.version = version;
}
@Column(length=64, nullable=false)
@Field(index=Index.TOKENIZED,store=Store.NO)
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@ElementCollection
// what do I put here??
public List<String> getKeywords() {
return keywords;
}
public void setKeywords(List<String> keywords) {
this.keywords = keywords;
}
}
如何注释关键字字段,以便我可以进行这样的搜索,对标题和关键字进行全文搜索:
org.apache.lucene.search.Query query = qb.keyword().onFields("title","keywords")
.matching("search").createQuery();