0
我有映射它看起来像:Hibernate Search的@IndexEmbedded组合集合中的一个领域
@Entity
@Table(name = "t_documents")
@Indexed(interceptor = DocumentIndexingInterceptor.class)
public class Document implements Serializable {
@Id
@GeneratedValue
@DocumentId
private Long id;
@IndexedEmbedded(prefix = "sections.", indexNullAs = "null",
includePaths = {"body"})
private List<Section> sections;
//...
}
@Entity
@Table(name = "t_sections")
@Indexed
public class Section implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@DocumentId
private Long id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "ndocumentid")
private Document document;
@Field(name = "body",
analyze = Analyze.YES,
index = Index.YES,
store = Store.NO,
norms = Norms.NO)
@Column(name = "vbody")
private String body;
//...
}
现在,如果我有两个实体部分的实体文件看起来像:
第1分体:“回答你自己题”;
第2节正文:“发布您的问题”;
*其他值并不重要。
当我看着卢克索引实体文档sections.body样子:
answer your own question post your question
当我搜索包含一句“回答后”的文件,将发现这个特定的文档。这不是我想要的结果。我希望只有在单个主体中找到搜索到的字符串时才能找到此文档。
这甚至可能吗?如果没有,有什么办法可以达到我想要的。
文件我的主要实体。它包含很多字段,如标题,状态,作者,日期等,所有这些都被索引和搜索。 作为结果我想要得到的查询,如'让我的文件,其中标题等于“某些标题”,任何部分包含单词“某些单词”' –
@JohnSmith好的。如果您不想明确列出包含的路径,则可以忽略它们:将包括所有字段。然后,如果您查询段索引而不是文档索引,则您提供的查询将翻译为“document.title:”某个标题“body:”某些词语“。 –