Skip to content

Commit

Permalink
[Fix] QueryRRF Response (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
EmadHanif01 authored Sep 12, 2023
1 parent 9fa2052 commit f786cad
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,19 @@ public EdgeChain<List<PostgresWordEmbeddings>> queryRRF(PostgresEndpoint postgre
val.setRawText(
Objects.nonNull(row.get("raw_text")) ? (String) row.get("raw_text") : null);

val.setFilename(
Objects.nonNull(row.get("filename"))
? (String) row.get("filename")
: null);
val.setTimestamp(
Objects.nonNull(row.get("timestamp"))
? ((Timestamp) row.get("timestamp")).toLocalDateTime()
: null);
val.setNamespace(
Objects.nonNull(row.get("namespace"))
? (String) row.get("namespace")
: null);

BigDecimal bigDecimal =
Objects.nonNull(row.get("rrf_score"))
? (BigDecimal) row.get("rrf_score")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public List<Map<String, Object>> queryRRF(

StringBuilder query = new StringBuilder();
query
.append("SELECT id, raw_text, document_date, metadata,\n")
.append("SELECT id, raw_text, document_date, metadata, namespace, filename, timestamp, \n")
.append(
String.format(
"%s / (ROW_NUMBER() OVER (ORDER BY text_rank DESC) + %s) + \n",
Expand All @@ -272,7 +272,7 @@ public List<Map<String, Object>> queryRRF(
"%s / (ROW_NUMBER() OVER (ORDER BY date_rank DESC) + %s) AS rrf_score\n",
dateWeight.getBaseWeight().getValue(), dateWeight.getFineTuneWeight()))
.append("FROM ( ")
.append("SELECT sv.id, sv.raw_text, svtm.document_date, svtm.metadata, ")
.append("SELECT sv.id, sv.raw_text, sv.namespace, sv.filename, sv.timestamp, svtm.document_date, svtm.metadata, ")
.append(
String.format(
"ts_rank_cd(sv.tsv, plainto_tsquery('%s', '%s')) AS text_rank, ",
Expand Down Expand Up @@ -318,7 +318,6 @@ public List<Map<String, Object>> queryRRF(
}

query.append(" LIMIT ").append(topK).append(";");

return jdbcTemplate.queryForList(query.toString());
}

Expand Down

0 comments on commit f786cad

Please sign in to comment.