elasticsearch8.6 elasticsearch-java 动态拼接 must should sort 怎么动态拼接?
// 组合查询
SearchResponse<Test> response6 = client.search(s -> s
.index("newapi") .query(q -> q
.bool(b -> b
.must(must -> must
.match(m -> m
.field("age")
.query(30)
)
)
.must(must -> must
.match(m -> m
.field("sex")
.query("男")
)
)
.should(should -> should
.match(m -> m
.field("age")
.query(30)
)
)
.should(should -> should
.match(m -> m
.field("age")
.query(40)
)
)
)
)
, Test.class);
System.out.println(response6.took());
System.out.println(response6.hits().total().value());
response6.hits().hits().forEach(e -> System.out.println(e.source().toString()));
就像上面这样 怎么动态拼接 must must should should sort 有排序条件就拼接 sort 有 或者条件 就拼接 should 没有或者不拼接 只拼接 must
以上是 elasticsearch8.6 elasticsearch-java 动态拼接 must should sort 怎么动态拼接? 的全部内容, 来源链接: utcz.com/p/945182.html