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,
});
Hi,
I am not sure, but looking at the code for the upstash search I see this:
Why don't you use the filter function like: