Browse Source

Fix index not found for new user. (#4597)

### What problem does this PR solve?

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
tags/v0.16.0
Kevin Hu 9 months ago
parent
commit
c4b9e903c8
No account linked to committer's email address
1 changed files with 8 additions and 2 deletions
  1. 8
    2
      api/apps/kb_app.py

+ 8
- 2
api/apps/kb_app.py View File

# limitations under the License. # limitations under the License.
# #
import json import json
import logging


from flask import request from flask import request
from flask_login import login_required, current_user from flask_login import login_required, current_user
message='No authorization.', message='No authorization.',
code=settings.RetCode.AUTHENTICATION_ERROR code=settings.RetCode.AUTHENTICATION_ERROR
) )
e, kb = KnowledgebaseService.get_by_id(kb_id)
_, kb = KnowledgebaseService.get_by_id(kb_id)
req = { req = {
"kb_id": [kb_id], "kb_id": [kb_id],
"knowledge_graph_kwd": ["graph"] "knowledge_graph_kwd": ["graph"]
} }
sres = settings.retrievaler.search(req, search.index_name(kb.tenant_id), [kb_id])
obj = {"graph": {}, "mind_map": {}} obj = {"graph": {}, "mind_map": {}}
try:
sres = settings.retrievaler.search(req, search.index_name(kb.tenant_id), [kb_id])
except Exception as e:
logging.exception(e)
return get_json_result(data=obj)

for id in sres.ids[:1]: for id in sres.ids[:1]:
ty = sres.field[id]["knowledge_graph_kwd"] ty = sres.field[id]["knowledge_graph_kwd"]
try: try:

Loading…
Cancel
Save