firecrawl / firecrawl/firestarter

Optimize upstash search

Open
#9 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
582
Forks
132
PR merge metrics
No merged PRs in 30d

Description

Hi,
I am not sure, but looking at the code for the upstash search I see this:

```
try {
// Search for documents - include namespace to improve relevance

// Include namespace in search to boost relevance
const searchQuery = `${query} ${namespace}`

const searchResults = await searchIndex.search({
query: searchQuery,
limit: config.search.maxResults,
reranking: true
})


// Filter to only include documents from the correct namespace
documents = searchResults.filter((doc) => {
const docNamespace = doc.metadata?.namespace
const matches = docNamespace === namespace
if (!matches && doc.metadata?.namespace) {
// Only log first few mismatches to avoid spam
if (documents.length < 3) {
}
}
return matches
})
....
```

Why don't you use the filter function like:

```
const searchResults = await searchIndex.search({
query: query,
limit: config.search.maxResults,
filter: `@metadata.namespace = "${namespace}"`,
reranking: true,
});
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Locate the Upstash search implementation containing the shown searchIndex.search call and read how namespace filtering currently works. Compare the proposed filter-based query with the existing post-search filtering, then validate that results remain limited to the requested namespace without reducing the intended relevance or result count.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend, search
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.