feat(repository): update keyword retrieval logic to use ParadeDB's matching operator
- Modified the SQL clause in the KeywordsRetrieve function to utilize ParadeDB's ||| operator for improved token matching. - Enhanced the handling of retrieval results in the fuseOrDeduplicate function to maintain original scores for keyword-only results, ensuring better performance in FAQ scenarios. This update optimizes the keyword retrieval process and improves the accuracy of search results.
This commit is contained in:
@@ -193,10 +193,13 @@ func (g *pgRepository) KeywordsRetrieve(ctx context.Context,
|
||||
Values: common.ToInterfaceSlice(params.TagIDs),
|
||||
})
|
||||
}
|
||||
|
||||
// Use ParadeDB's ||| operator for matching any token
|
||||
conds = append(conds, clause.Expr{
|
||||
SQL: "id @@@ paradedb.match(field => 'content', value => ?, distance => 1)",
|
||||
SQL: "content ||| ?",
|
||||
Vars: []interface{}{params.Query},
|
||||
})
|
||||
|
||||
// Filter by is_enabled = true or NULL (NULL means enabled for historical data)
|
||||
conds = append(conds, clause.Expr{
|
||||
SQL: "(is_enabled IS NULL OR is_enabled = ?)",
|
||||
|
||||
Reference in New Issue
Block a user