Skip to content

Milvus Vector - Unable to Set nprobe in doSimilaritySearch for Default IVF_FLAT When initializeSchema = true #2294

@waileong

Description

@waileong

Milvus Vector - Unable to Set nprobe in doSimilaritySearch for Default IVF_FLAT When initializeSchema = true

Description

We are encountering an issue in MilvusVectorStore where it is not possible to set nprobe when performing similarity searches (doSimilaritySearch) if the index type is IVF_FLAT.

By default, IVF_FLAT is selected when initializeSchema = true, but nprobe is not explicitly set, leading to poor recall or zero results in some cases.

Expected Behavior

  • Users should be able to set nprobe when performing similarity searches with IVF_FLAT.
  • A way to override nprobe in doSimilaritySearch() should be provided via either:
    • A configurable parameter in SearchRequest
    • A fallback to a reasonable default value (e.g., nprobe = 256)

Current Behavior

  • IVF_FLAT is used as the default index, but nprobe is not explicitly set in doSimilaritySearch().
  • This leads to low recall or 0 search results if nprobe defaults to a very small value (1).
  • There is no exposed method to override nprobe in SearchRequest.

Steps to Reproduce

  1. Initialize a MilvusVectorStore instance with initializeSchema = true.
  2. Add some vector data to the store.
  3. Perform a similarity search using doSimilaritySearch().
  4. Observe that nprobe is not explicitly set, leading to poor recall or zero results.

Code Example:

MilvusVectorStore vectorStore = MilvusVectorStore.builder(milvusClient, embeddingModel)
    .initializeSchema(true)  // Uses default IVF_FLAT
    .build();

SearchRequest searchRequest = SearchRequest.query("example query")
    .withTopK(5)
    .withSimilarityThreshold(0.7);  // No way to set nprobe

List<Document> results = vectorStore.similaritySearch(searchRequest);

// Expecting search results, but sometimes returns 0 records due to missing nprobe

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions