Skip to content

Commit

Permalink
Fix score() issue (infiniflow#4194)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

as title

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

Signed-off-by: jinhai <haijin.chn@gmail.com>
  • Loading branch information
JinHai-CN authored and baifachuan committed Dec 26, 2024
1 parent 2033c5e commit 9d83a73
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions rag/utils/infinity_conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ def concat_dataframes(df_list: list[pl.DataFrame], selectFields: list[str]) -> p
if df_list:
return pl.concat(df_list)
schema = dict()
for fieldnm in selectFields:
schema[fieldnm] = str
for field_name in selectFields:
if field_name == 'score()': # Workaround: fix schema is changed to score()
schema['SCORE'] = str
else:
schema[field_name] = str
return pl.DataFrame(schema=schema)

@singleton
Expand Down Expand Up @@ -342,7 +345,7 @@ def search(
self.connPool.release_conn(inf_conn)
res = concat_dataframes(df_list, selectFields)
if matchExprs:
res = res.sort(pl.col("score()") + pl.col("pagerank_fea"), descending=True, maintain_order=True)
res = res.sort(pl.col("SCORE") + pl.col("pagerank_fea"), descending=True, maintain_order=True)
res = res.limit(limit)
logger.debug(f"INFINITY search final result: {str(res)}")
return res, total_hits_count
Expand Down

0 comments on commit 9d83a73

Please sign in to comment.