|
@@ -44,10 +44,6 @@ class SearchBusiness:
|
|
},
|
|
},
|
|
"sort": [{"_score": {"order": "desc"}}]
|
|
"sort": [{"_score": {"order": "desc"}}]
|
|
}
|
|
}
|
|
- if limit:
|
|
|
|
- query["size"] = limit
|
|
|
|
- if from_:
|
|
|
|
- query["from"] = from_
|
|
|
|
|
|
|
|
if name:
|
|
if name:
|
|
query["query"]["bool"]["must"].append({"match": {"public_kg_nodes_name": name}})
|
|
query["query"]["bool"]["must"].append({"match": {"public_kg_nodes_name": name}})
|
|
@@ -55,9 +51,16 @@ class SearchBusiness:
|
|
query["query"]["bool"]["must"].append({"term": {"public_kg_nodes_id": id}})
|
|
query["query"]["bool"]["must"].append({"term": {"public_kg_nodes_id": id}})
|
|
if ids:
|
|
if ids:
|
|
query["query"]["bool"]["must"].append({"terms": {"public_kg_nodes_id": ids}})
|
|
query["query"]["bool"]["must"].append({"terms": {"public_kg_nodes_id": ids}})
|
|
|
|
+ limit = 2000
|
|
|
|
+ from_ = None
|
|
if type:
|
|
if type:
|
|
query["query"]["bool"]["must"].append({"match": {"public_kg_nodes_category": type}})
|
|
query["query"]["bool"]["must"].append({"match": {"public_kg_nodes_category": type}})
|
|
|
|
|
|
|
|
+ if limit:
|
|
|
|
+ query["size"] = limit
|
|
|
|
+ if from_:
|
|
|
|
+ query["from"] = from_
|
|
|
|
+
|
|
results = self.search_nodes_and_edges(index="connector-postgresql-all", query=query)
|
|
results = self.search_nodes_and_edges(index="connector-postgresql-all", query=query)
|
|
return results
|
|
return results
|
|
except exceptions.NotFoundError as e:
|
|
except exceptions.NotFoundError as e:
|
|
@@ -67,7 +70,7 @@ class SearchBusiness:
|
|
logger.error(f"Search error: {e}")
|
|
logger.error(f"Search error: {e}")
|
|
return None
|
|
return None
|
|
|
|
|
|
- def search_edges(self,name,src_id):
|
|
|
|
|
|
+ def search_edges(self,name=None,src_id=None,size=None):
|
|
try:
|
|
try:
|
|
query = {
|
|
query = {
|
|
"query": {
|
|
"query": {
|
|
@@ -83,6 +86,8 @@ class SearchBusiness:
|
|
query["query"]["bool"]["must"].append({"match": {"public_kg_edges_category": name}})
|
|
query["query"]["bool"]["must"].append({"match": {"public_kg_edges_category": name}})
|
|
if src_id:
|
|
if src_id:
|
|
query["query"]["bool"]["must"].append({"term": {"public_kg_edges_src_id": src_id}})
|
|
query["query"]["bool"]["must"].append({"term": {"public_kg_edges_src_id": src_id}})
|
|
|
|
+ if size:
|
|
|
|
+ query["size"] = size
|
|
|
|
|
|
results = self.search_nodes_and_edges(index="connector-postgresql-all", query=query)
|
|
results = self.search_nodes_and_edges(index="connector-postgresql-all", query=query)
|
|
return results
|
|
return results
|
|
@@ -222,7 +227,7 @@ class SearchBusiness:
|
|
return {"concepts": concepts}
|
|
return {"concepts": concepts}
|
|
|
|
|
|
def get_relations(self, src_id):
|
|
def get_relations(self, src_id):
|
|
- edges = self.search_edges(name=None, src_id=src_id)
|
|
|
|
|
|
+ edges = self.search_edges(src_id=src_id, size=2000)
|
|
if not edges:
|
|
if not edges:
|
|
return {"relations": []}
|
|
return {"relations": []}
|
|
|
|
|