mirror of
https://github.com/qdrant/qdrant.git
synced 2026-07-23 11:11:00 -05:00
Return complete error for sparse vector validation (#5536)
* Return complete error for sparse vector validation * remove unecessary path * update test to show new value
This commit is contained in:
@@ -464,12 +464,11 @@ impl TryFrom<grpc::Vector> for VectorInternal {
|
||||
// sparse vector
|
||||
if let Some(indices) = vector.indices {
|
||||
return Ok(VectorInternal::Sparse(
|
||||
sparse::common::sparse_vector::SparseVector::new(indices.data, vector.data)
|
||||
.map_err(|e| {
|
||||
Status::invalid_argument(format!(
|
||||
"Sparse indices does not match sparse vector conditions: {e}"
|
||||
))
|
||||
})?,
|
||||
SparseVector::new(indices.data, vector.data).map_err(|e| {
|
||||
Status::invalid_argument(format!(
|
||||
"Sparse indices does not match sparse vector conditions: {e}"
|
||||
))
|
||||
})?,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
@@ -1709,8 +1709,10 @@ pub fn into_named_vector_struct(
|
||||
Some(indices) => NamedVectorStruct::Sparse(NamedSparseVector {
|
||||
name: vector_name
|
||||
.ok_or_else(|| Status::invalid_argument("Sparse vector must have a name"))?,
|
||||
vector: SparseVector::new(indices.data, vector).map_err(|_| {
|
||||
Status::invalid_argument("Sparse indices does not match sparse vector conditions")
|
||||
vector: SparseVector::new(indices.data, vector).map_err(|e| {
|
||||
Status::invalid_argument(format!(
|
||||
"Sparse indices does not match sparse vector conditions: {e}"
|
||||
))
|
||||
})?,
|
||||
}),
|
||||
None => {
|
||||
@@ -1957,10 +1959,10 @@ impl TryFrom<SearchPointGroups> for rest::SearchGroupsRequestInternal {
|
||||
|
||||
if let Some(sparse_indices) = &search_points.sparse_indices {
|
||||
validate_sparse_vector_impl(&sparse_indices.data, &search_points.vector).map_err(
|
||||
|_| {
|
||||
Status::invalid_argument(
|
||||
"Sparse indices does not match sparse vector conditions",
|
||||
)
|
||||
|e| {
|
||||
Status::invalid_argument(format!(
|
||||
"Sparse indices does not match sparse vector conditions: {e}"
|
||||
))
|
||||
},
|
||||
)?;
|
||||
}
|
||||
|
||||
@@ -932,8 +932,10 @@ impl TryFrom<api::grpc::qdrant::SearchPoints> for CoreSearchRequest {
|
||||
} = value;
|
||||
|
||||
if let Some(sparse_indices) = &sparse_indices {
|
||||
validate_sparse_vector_impl(&sparse_indices.data, &vector).map_err(|_| {
|
||||
Status::invalid_argument("Sparse indices does not match sparse vector conditions")
|
||||
validate_sparse_vector_impl(&sparse_indices.data, &vector).map_err(|e| {
|
||||
Status::invalid_argument(format!(
|
||||
"Sparse indices does not match sparse vector conditions: {e}"
|
||||
))
|
||||
})?;
|
||||
}
|
||||
|
||||
@@ -1265,9 +1267,9 @@ impl TryFrom<api::grpc::qdrant::VectorExample> for RecommendExample {
|
||||
match vector.indices {
|
||||
Some(indices) => {
|
||||
validate_sparse_vector_impl(&indices.data, &vector.data).map_err(
|
||||
|_| {
|
||||
|e| {
|
||||
Status::invalid_argument(
|
||||
"Sparse indices does not match sparse vector conditions",
|
||||
format!("Sparse indices does not match sparse vector conditions: {e}"),
|
||||
)
|
||||
},
|
||||
)?;
|
||||
|
||||
@@ -175,7 +175,7 @@ response=$(
|
||||
"limit": 3
|
||||
}' $QDRANT_HOST qdrant.Points/Search 2>&1
|
||||
)
|
||||
if [[ $response != *"Sparse indices does not match sparse vector conditions"* ]]; then
|
||||
if [[ $response != *"Sparse indices does not match sparse vector conditions: values: Validation error: must be the same length as indices [{}]"* ]]; then
|
||||
echo Unexpected response, expected validation error: $response
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user