mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Fix: search highlight. (#10616)
### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -60,7 +60,7 @@ def list_chunk():
|
|||||||
}
|
}
|
||||||
if "available_int" in req:
|
if "available_int" in req:
|
||||||
query["available_int"] = int(req["available_int"])
|
query["available_int"] = int(req["available_int"])
|
||||||
sres = settings.retriever.search(query, search.index_name(tenant_id), kb_ids, highlight=True)
|
sres = settings.retriever.search(query, search.index_name(tenant_id), kb_ids, highlight=["content_ltks"])
|
||||||
res = {"total": sres.total, "chunks": [], "doc": doc.to_dict()}
|
res = {"total": sres.total, "chunks": [], "doc": doc.to_dict()}
|
||||||
for id in sres.ids:
|
for id in sres.ids:
|
||||||
d = {
|
d = {
|
||||||
|
|||||||
@ -72,7 +72,7 @@ class Dealer:
|
|||||||
def search(self, req, idx_names: str | list[str],
|
def search(self, req, idx_names: str | list[str],
|
||||||
kb_ids: list[str],
|
kb_ids: list[str],
|
||||||
emb_mdl=None,
|
emb_mdl=None,
|
||||||
highlight=False,
|
highlight: bool | list = False,
|
||||||
rank_feature: dict | None = None
|
rank_feature: dict | None = None
|
||||||
):
|
):
|
||||||
filters = self.get_filters(req)
|
filters = self.get_filters(req)
|
||||||
@ -101,7 +101,11 @@ class Dealer:
|
|||||||
total = self.dataStore.getTotal(res)
|
total = self.dataStore.getTotal(res)
|
||||||
logging.debug("Dealer.search TOTAL: {}".format(total))
|
logging.debug("Dealer.search TOTAL: {}".format(total))
|
||||||
else:
|
else:
|
||||||
highlightFields = ["content_ltks", "title_tks"] if highlight else []
|
highlightFields = ["content_ltks", "title_tks"]
|
||||||
|
if not highlight:
|
||||||
|
highlightFields = []
|
||||||
|
elif isinstance(highlight, list):
|
||||||
|
highlightFields = highlight
|
||||||
matchText, keywords = self.qryr.question(qst, min_match=0.3)
|
matchText, keywords = self.qryr.question(qst, min_match=0.3)
|
||||||
if emb_mdl is None:
|
if emb_mdl is None:
|
||||||
matchExprs = [matchText]
|
matchExprs = [matchText]
|
||||||
|
|||||||
Reference in New Issue
Block a user