mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-08-14 01:25:52 +08:00
Make the update script shorter. (#4854)
### What problem does this PR solve? ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
parent
bc68f18c48
commit
0d3ed37b48
@ -5,9 +5,6 @@
|
|||||||
"number_of_replicas": 0,
|
"number_of_replicas": 0,
|
||||||
"refresh_interval": "1000ms"
|
"refresh_interval": "1000ms"
|
||||||
},
|
},
|
||||||
"persistent" : {
|
|
||||||
"script.max_compilations_rate" : "200/10m"
|
|
||||||
},
|
|
||||||
"similarity": {
|
"similarity": {
|
||||||
"scripted_sim": {
|
"scripted_sim": {
|
||||||
"type": "scripted",
|
"type": "scripted",
|
||||||
|
@ -244,11 +244,16 @@ class KGSearch(Dealer):
|
|||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
rel["description"] = rela["description"]
|
rel["description"] = rela["description"]
|
||||||
|
desc = rel["description"]
|
||||||
|
try:
|
||||||
|
desc = json.loads(desc).get("description", "")
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
relas.append({
|
relas.append({
|
||||||
"From Entity": f,
|
"From Entity": f,
|
||||||
"To Entity": t,
|
"To Entity": t,
|
||||||
"Score": "%.2f" % (rel["sim"] * rel["pagerank"]),
|
"Score": "%.2f" % (rel["sim"] * rel["pagerank"]),
|
||||||
"Description": json.loads(rel["description"]).get("description", "")
|
"Description": desc
|
||||||
})
|
})
|
||||||
max_token -= num_tokens_from_string(str(relas[-1]))
|
max_token -= num_tokens_from_string(str(relas[-1]))
|
||||||
if max_token <= 0:
|
if max_token <= 0:
|
||||||
|
@ -367,11 +367,13 @@ class ESConnection(DocStoreConnection):
|
|||||||
continue
|
continue
|
||||||
if isinstance(v, str):
|
if isinstance(v, str):
|
||||||
v = re.sub(r"(['\n\r]|\\.)", " ", v)
|
v = re.sub(r"(['\n\r]|\\.)", " ", v)
|
||||||
scripts.append(f"ctx._source.{k}='{v}';")
|
params[f"pp_{k}"] = v
|
||||||
|
scripts.append(f"ctx._source.{k}=params.pp_{k};")
|
||||||
elif isinstance(v, int) or isinstance(v, float):
|
elif isinstance(v, int) or isinstance(v, float):
|
||||||
scripts.append(f"ctx._source.{k}={v};")
|
scripts.append(f"ctx._source.{k}={v};")
|
||||||
elif isinstance(v, list):
|
elif isinstance(v, list):
|
||||||
scripts.append(f"ctx._source.{k}={json.dumps(v, ensure_ascii=False)};")
|
scripts.append(f"ctx._source.{k}=params.pp_{k};")
|
||||||
|
params[f"pp_{k}"] = json.dumps(v, ensure_ascii=False)
|
||||||
else:
|
else:
|
||||||
raise Exception(
|
raise Exception(
|
||||||
f"newValue `{str(k)}={str(v)}` value type is {str(type(v))}, expected to be int, str.")
|
f"newValue `{str(k)}={str(v)}` value type is {str(type(v))}, expected to be int, str.")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user