|
@@ -269,12 +269,19 @@ public class EsService {
|
|
|
* @param projectId
|
|
|
* @return
|
|
|
*/
|
|
|
- public Boolean search(String parentId, Integer projectId){
|
|
|
+ public Boolean search(String parentId, Integer projectId) throws IOException {
|
|
|
boolean flag = false;
|
|
|
+ SearchRequest.Builder builder = new SearchRequest.Builder();
|
|
|
+ //设置查询索引
|
|
|
+ builder.index("patent");
|
|
|
+
|
|
|
Query q1 = QueryBuilders.term(t -> t.field("project_id").value(projectId));
|
|
|
Query q2 = QueryBuilders.parentId(parent -> parent.type("project").id(parentId));
|
|
|
Query bool = QueryBuilders.bool(i -> i.must(q1, q2));
|
|
|
- if (bool != null) {
|
|
|
+ builder.query(bool);
|
|
|
+ SearchResponse<Patent> response = client.search(builder.build(), Patent.class);
|
|
|
+ long total = response.hits().total().value();
|
|
|
+ if (total > 0) {
|
|
|
flag = true;
|
|
|
}
|
|
|
return flag;
|