Skip to content

Conversation

@erudzitis
Copy link
Contributor

Fixes #8746

Problem:
unescaped RegExp(term) throws on **, [, ?, etc., crashing BM25 based retrieval functionality

Fix:
escape metacharacters via term.replace(/[.*+?^${}()|[\\]\\\\]/g, "\\\\$&") before constructing RegExp

@vercel
Copy link

vercel bot commented Aug 21, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
langchainjs-docs Ready Ready Preview Sep 1, 2025 6:17am
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
langchainjs-api-refs Ignored Ignored Sep 1, 2025 6:17am

@hntrl hntrl merged commit cd5f6fc into langchain-ai:main Sep 1, 2025
32 checks passed
hntrl added a commit that referenced this pull request Oct 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BM25Retriever crashes on queries with markdown / regex characters (unescaped getTermFrequency regex)

3 participants