Don't write an empty _vectors field

This commit is contained in:
Louis Dureuil 2024-05-14 11:51:27 +02:00
parent 2f7a8a4efb
commit 0462ebbe58
No known key found for this signature in database

View File

@ -234,18 +234,25 @@ pub(crate) fn write_typed_chunk_into_index(
addition, addition,
) )
else { else {
break 'vectors addition; break 'vectors Some(addition);
}; };
vectors.retain_user_provided_vectors(); vectors.retain_user_provided_vectors();
serde_json::to_writer(&mut vectors_buffer, &vectors.0) let crate::vector::parsed_vectors::ParsedVectors(vectors) = vectors;
.map_err(InternalError::SerdeJson)?; if vectors.is_empty() {
&vectors_buffer break 'vectors None;
} }
_ => addition,
serde_json::to_writer(&mut vectors_buffer, &vectors)
.map_err(InternalError::SerdeJson)?;
Some(vectors_buffer.as_slice())
}
_ => Some(addition),
}; };
if let Some(addition) = addition {
writer.insert(field_id, addition)?; writer.insert(field_id, addition)?;
} }
} }
}
let db = index.documents.remap_data_type::<Bytes>(); let db = index.documents.remap_data_type::<Bytes>();