Merge pull request #5886 from meilisearch/fix-decoding-error

Allow missing `search_fragments` and `indexing_fragments`
This commit is contained in:
Tamo
2025-09-11 14:13:57 +00:00
committed by GitHub
8 changed files with 60 additions and 0 deletions

View File

@ -12,6 +12,12 @@ use crate::vector::settings::RemoveFragments;
use crate::vector::EmbeddingConfig; use crate::vector::EmbeddingConfig;
use crate::{CboRoaringBitmapCodec, DocumentId, UserError}; use crate::{CboRoaringBitmapCodec, DocumentId, UserError};
/// DB representation of an embedder configuration.
///
/// # Warning
///
/// This type is serialized in and deserialized from the DB, any modification should either go
/// through dumpless upgrade or be backward-compatible
#[derive(Debug, Deserialize, Serialize)] #[derive(Debug, Deserialize, Serialize)]
pub struct IndexEmbeddingConfig { pub struct IndexEmbeddingConfig {
pub name: String, pub name: String,

View File

@ -24,6 +24,12 @@ pub enum SubEmbedder {
Rest(rest::Embedder), Rest(rest::Embedder),
} }
/// Options of a subembedder, specific to each kind of embedder.
///
/// # Warning
///
/// This type is serialized in and deserialized from the DB, any modification should either go
/// through dumpless upgrade or be backward-compatible
#[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Deserialize, serde::Serialize)] #[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Deserialize, serde::Serialize)]
pub enum SubEmbedderOptions { pub enum SubEmbedderOptions {
HuggingFace(hf::EmbedderOptions), HuggingFace(hf::EmbedderOptions),
@ -51,6 +57,12 @@ pub struct Embedder {
pub(super) index: SubEmbedder, pub(super) index: SubEmbedder,
} }
/// Options of a composite embedder, specific to each kind of embedder.
///
/// # Warning
///
/// This type is serialized in and deserialized from the DB, any modification should either go
/// through dumpless upgrade or be backward-compatible
#[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Deserialize, serde::Serialize)] #[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Deserialize, serde::Serialize)]
pub struct EmbedderOptions { pub struct EmbedderOptions {
pub search: SubEmbedderOptions, pub search: SubEmbedderOptions,

View File

@ -30,6 +30,12 @@ enum WeightSource {
Pytorch, Pytorch,
} }
/// Inert embedder options for a hf embedder.
///
/// # Warning
///
/// This type is serialized in and deserialized from the DB, any modification should either go
/// through dumpless upgrade or be backward-compatible
#[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Deserialize, serde::Serialize)] #[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Deserialize, serde::Serialize)]
pub struct EmbedderOptions { pub struct EmbedderOptions {
pub model: String, pub model: String,

View File

@ -7,6 +7,12 @@ pub struct Embedder {
distribution: Option<DistributionShift>, distribution: Option<DistributionShift>,
} }
/// Inert embedder options for a manual embedder.
///
/// # Warning
///
/// This type is serialized in and deserialized from the DB, any modification should either go
/// through dumpless upgrade or be backward-compatible
#[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Deserialize, serde::Serialize)] #[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Deserialize, serde::Serialize)]
pub struct EmbedderOptions { pub struct EmbedderOptions {
pub dimensions: usize, pub dimensions: usize,

View File

@ -35,6 +35,11 @@ pub enum Embedder {
} }
/// Configuration for an embedder. /// Configuration for an embedder.
///
/// # Warning
///
/// This type is serialized in and deserialized from the DB, any modification should either go
/// through dumpless upgrade or be backward-compatible
#[derive(Debug, Clone, Default, serde::Deserialize, serde::Serialize)] #[derive(Debug, Clone, Default, serde::Deserialize, serde::Serialize)]
pub struct EmbeddingConfig { pub struct EmbeddingConfig {
/// Options of the embedder, specific to each kind of embedder /// Options of the embedder, specific to each kind of embedder
@ -53,6 +58,11 @@ impl EmbeddingConfig {
} }
/// Options of an embedder, specific to each kind of embedder. /// Options of an embedder, specific to each kind of embedder.
///
/// # Warning
///
/// This type is serialized in and deserialized from the DB, any modification should either go
/// through dumpless upgrade or be backward-compatible
#[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Deserialize, serde::Serialize)] #[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Deserialize, serde::Serialize)]
pub enum EmbedderOptions { pub enum EmbedderOptions {
HuggingFace(hf::EmbedderOptions), HuggingFace(hf::EmbedderOptions),

View File

@ -16,6 +16,12 @@ pub struct Embedder {
rest_embedder: RestEmbedder, rest_embedder: RestEmbedder,
} }
/// Inert embedder options for an ollama embedder.
///
/// # Warning
///
/// This type is serialized in and deserialized from the DB, any modification should either go
/// through dumpless upgrade or be backward-compatible
#[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Deserialize, serde::Serialize)] #[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Deserialize, serde::Serialize)]
pub struct EmbedderOptions { pub struct EmbedderOptions {
pub embedding_model: String, pub embedding_model: String,

View File

@ -13,6 +13,12 @@ use crate::vector::error::{EmbedError, EmbedErrorKind, NewEmbedderError};
use crate::vector::{Embedding, REQUEST_PARALLELISM}; use crate::vector::{Embedding, REQUEST_PARALLELISM};
use crate::ThreadPoolNoAbort; use crate::ThreadPoolNoAbort;
/// Inert embedder options for an openai embedder.
///
/// # Warning
///
/// This type is serialized in and deserialized from the DB, any modification should either go
/// through dumpless upgrade or be backward-compatible
#[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Deserialize, serde::Serialize)] #[derive(Debug, Clone, Hash, PartialEq, Eq, serde::Deserialize, serde::Serialize)]
pub struct EmbedderOptions { pub struct EmbedderOptions {
pub url: Option<String>, pub url: Option<String>,

View File

@ -133,6 +133,12 @@ impl RequestData {
} }
} }
/// Inert embedder options for a rest embedder.
///
/// # Warning
///
/// This type is serialized in and deserialized from the DB, any modification should either go
/// through dumpless upgrade or be backward-compatible
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)] #[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
pub struct EmbedderOptions { pub struct EmbedderOptions {
pub api_key: Option<String>, pub api_key: Option<String>,
@ -140,7 +146,9 @@ pub struct EmbedderOptions {
pub dimensions: Option<usize>, pub dimensions: Option<usize>,
pub url: String, pub url: String,
pub request: Value, pub request: Value,
#[serde(default)] // backward compatibility
pub search_fragments: BTreeMap<String, Value>, pub search_fragments: BTreeMap<String, Value>,
#[serde(default)] // backward compatibility
pub indexing_fragments: BTreeMap<String, Value>, pub indexing_fragments: BTreeMap<String, Value>,
pub response: Value, pub response: Value,
pub headers: BTreeMap<String, String>, pub headers: BTreeMap<String, String>,