-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
Collection::search panics at src/collection.rs:532 when the Milvus server returns a search response with no matching results. The ids or id_field field in the response can be None when there are zero hits, but the current code calls .unwrap() unconditionally.
// src/collection.rs:532
let raw_id = raw_data.ids.unwrap().id_field.unwrap();This causes a hard panic (called Option::unwrap() on a None value) instead of returning an empty Vec<SearchResult>.
Expected Behavior
search should return Ok(vec![]) (or a Vec<SearchResult> with size: 0) when there are no matching results.
Actual Behavior
thread 'tokio-runtime-worker' panicked at
/Users/.../.cargo/registry/src/.../milvus-sdk-rust-0.1.0/src/collection.rs:532:35:
called `Option::unwrap()` on a `None` value
Steps/Code To Reproduce behavior
1. Create a empty collection and load it.
2. Perform a search with a filter expression that matches **no** documents, e.g.:
let collection = client.get_collection("my_collection").await?;
let mut options = SearchOption::new();
options.set_expr(r#"some_field in ["non_existent_id"]"#);
options.add_param("nprobe", json!(16));
// This panics instead of returning an empty Vec
let results = collection.search(
vec![Value::FloatArray(vec![0.1; 512])],
"vector",
10,
MetricType::IP,
vec!["some_field"],
&options,
).await?;Environment details
- **milvus-sdk-rust version**: 0.1.0
- **Milvus server version**: 2.x
- **Rust version**: stable (1.8x)
- **OS**: macOS (aarch64) / LinuxReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels