mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-13 22:55:58 +08:00
Ignore exception of empty index. (#5030)
### What problem does this PR solve? ### Type of change - [x] Refactoring
This commit is contained in:
parent
2ddf278e2d
commit
3aa5c2a699
@ -14,7 +14,6 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
|
||||
from flask import request
|
||||
@ -300,11 +299,12 @@ def knowledge_graph(kb_id):
|
||||
"kb_id": [kb_id],
|
||||
"knowledge_graph_kwd": ["graph"]
|
||||
}
|
||||
|
||||
obj = {"graph": {}, "mind_map": {}}
|
||||
try:
|
||||
if not settings.docStoreConn.indexExist(search.index_name(kb.tenant_id)):
|
||||
return get_json_result(data=obj)
|
||||
sres = settings.retrievaler.search(req, search.index_name(kb.tenant_id), [kb_id])
|
||||
except Exception as e:
|
||||
logging.exception(e)
|
||||
if not len(sres.ids):
|
||||
return get_json_result(data=obj)
|
||||
|
||||
for id in sres.ids[:1]:
|
||||
|
@ -113,7 +113,7 @@ class ESConnection(DocStoreConnection):
|
||||
except Exception:
|
||||
logger.exception("ESConnection.deleteIdx error %s" % (indexName))
|
||||
|
||||
def indexExist(self, indexName: str, knowledgebaseId: str) -> bool:
|
||||
def indexExist(self, indexName: str, knowledgebaseId: str = None) -> bool:
|
||||
s = Index(indexName, self.es)
|
||||
for i in range(ATTEMPT_TIME):
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user