Vector Search Low performance pre filtering

Hello, I have a collection with an embedding field and other fields with 2 million records, when I perform the filter in $vectorsearch, it becomes very slow

var pipeline = new
{
new BsonDocument(“$vectorSearch”, new BsonDocument
{
{ “index”, indexName },
{ “path”, “embedding” },
{ “queryVector”, new BsonArray(parameter.Embeddings) },
{ “numCandidates”, 150 },
{ “limit”, 100 },
{ “exact”, false },
{ “filter”, new BsonDocument{{ “CountryCode”, “USA” }} }
})
};

var results = await context.Database.GetCollection(“Embedding”).Aggregate(pipeline).ToListAsync();

here is my index

{
“fields”: [
{
“numDimensions”: 768,
“path”: “embedding”,
“similarity”: “cosine”,
“type”: “vector”
},
{
“path”: “CountryCode”,
“type”: “filter”
}
]
}

Hi @Carlos_Y_Oviedo_Becerra! Thanks for posting your question, I should be able to help out here.

Can you share more about the resources you are building the search index on? An index of that size without quantization should require roughly 6 GB of memory in filesystem cache to yield performant queries. If you aren’t using dedicated search nodes, this might take a bit longer to serve queries initially due to initial cache warmup of the vector values.

Hi @Henry_Weller I am attaching the image of serve in mongo db, i am using dedicate search nodes

Enabling quantization (either scalar or binary) in your index definition for your vector field should resolve this issue without needing more memory. You can learn more about how to do this here.