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:

```java 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 results = vectorStore.similaritySearch(searchRequest);

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

Comment From: dev-jonghoonpark

related document : https://milvus.io/docs/ivf-flat.md