|
@@ -171,4 +171,33 @@ public class EsProductPatentService {
|
|
|
String id= esService.addChildPatent(patent,patentId);
|
|
|
return id;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询商品化专利架构相关数量
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ public Long selectRelevantTreeNodeNum(Integer id,Integer type) throws Exception {
|
|
|
+ SearchRequest.Builder builder = new SearchRequest.Builder();
|
|
|
+ String fieldType="9";
|
|
|
+ if(type==1){
|
|
|
+ fieldType="8";
|
|
|
+ }
|
|
|
+ String finalFieldType =fieldType;
|
|
|
+ //设置查询索引
|
|
|
+ builder.index("patent");
|
|
|
+ Query q1 = QueryBuilders.match(t -> t.field("custom_field.field_value").query(id));
|
|
|
+ Query q2 = QueryBuilders.term(t -> t.field("custom_field.field_type").value(finalFieldType));
|
|
|
+ Query bool = QueryBuilders.bool(i -> i.must(q1,q2));
|
|
|
+ Query query = QueryBuilders.hasChild(n -> n.type("project_customfield").query(bool));
|
|
|
+ builder.query(query);
|
|
|
+ SearchResponse<Patent> response = null;
|
|
|
+ try {
|
|
|
+ response = client.search(builder.build(), Patent.class);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new XiaoShiException(ExceptionEnum.BUSINESS_ERROR, "ES检索失败");
|
|
|
+ }
|
|
|
+ return response.hits().total().value();
|
|
|
+ }
|
|
|
}
|