Browse Source

Fix: Add pagerank validation for non-elasticsearch doc engines (#8215)

### What problem does this PR solve?

Validate that pagerank updates are only allowed when using elasticsearch
as the document engine. Return an error if pagerank is set while using a
different doc engine, preventing potential inconsistencies in document
scoring.

#8208

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
tags/v0.19.1
Liu An 4 months ago
parent
commit
d0c5ff04a6
No account linked to committer's email address
1 changed files with 3 additions and 0 deletions
  1. 3
    0
      api/apps/kb_app.py

+ 3
- 0
api/apps/kb_app.py View File

@@ -124,6 +124,9 @@ def update():
return get_data_error_result()

if kb.pagerank != req.get("pagerank", 0):
if os.environ.get("DOC_ENGINE", "elasticsearch") != "elasticsearch":
return get_data_error_result(message="'pagerank' can only be set when doc_engine is elasticsearch")
if req.get("pagerank", 0) > 0:
settings.docStoreConn.update({"kb_id": kb.id}, {PAGERANK_FLD: req["pagerank"]},
search.index_name(kb.tenant_id), kb.id)

Loading…
Cancel
Save