我有这样的结构:
@Indexed
class MainObject {
@Id
@Column(name = "ID", nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO)
Long id;
@IndexedEmbedded
@OneToMany
List<ObjectLevel1> objectLevel1 ;
}
@Indexed
class ObjectLevel1 {
@Id
@Column(name = "ID", nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO)
Long id;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "", nullable = false)
@IndexedEmbedded
ObjectLevel2 objectLevel2;
@Field(index = Index.YES, store = Store.YES, analyze = Analyze.NO)
Long value;
}
class ObjectLevel2 {
@Id
@Column(name = "ID", nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO)
Long id
}
为MainObject.class
创建了FullTextQuery当我查询+(+ objectLevel1.objectLevel2.id:141 + objectLevel1.value:5)时,我希望只获得具有objectLevel1.value和objectLevel1.objectLevel2.id的这些结果,但我和#39; m得到混合结果,如objectLevel1.value或objectLevel1.objectLevel.id
如何查询满足这两个条件的get结果?
编辑:更新了模型的注释并添加到查询代码下面:
q1.add(new TermQuery(new Term("objectLevel1.objectLevel2.id", s
.getValue().toString())), BooleanClause.Occur.MUST);
q1.add(new TermQuery(new Term(
"objectLevel1.value", s.getValue()
.toString())), BooleanClause.Occur.MUST);
query.add(q1, BooleanClause.Occur.MUST);