Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion langchain_postgres/v2/async_vectorstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ async def __query_collection(
if hybrid_search_config.tsv_lang
else ""
)
query_tsv = f"plainto_tsquery({lang} :fts_query)"
query_tsv = fr"websearch_to_tsquery({lang} regexp_replace(:fts_query, '\s', ' OR ', 'g'))"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree we should be using the regex to enforce OR. This will not match the user's expectation of using FTS with the user's query.

Copy link
Author

@raphaelgurtner raphaelgurtner Nov 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick answer! Interesting, I’ve been discussing expected behavior with a few of my colleagues and all seemed to expect the OR behavior.
The current behavior seems unexpected for queries like

  • “very specific terms that result in perfect chunk retrieval with FTS”

vs.

  • “very specific terms that result in perfect chunk retrieval with FTS, thank you”

As long as these queries/user prompts are passed to the retriever as-is it’s highly likely that the second query returns no result at all.

We found that behavior odd one loses the benefit of the FTS part of the hybrid search in most cases, at least in our testing.

what would you think about making the behavior configurable in HybridSearchConfig?

param_dict["fts_query"] = fts_query
if hybrid_search_config.tsv_column:
content_tsv = f'"{hybrid_search_config.tsv_column}"'
Expand Down