# This file was auto-generated by Fern from our API Definition.

from ..core.pydantic_utilities import UniversalBaseModel
import typing
import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2


class IndividualSearchResult(UniversalBaseModel):
    """
    An individual ranked search result from a query.
    """

    text: typing.Optional[str] = pydantic.Field(default=None)
    """
    The document part altered by the context configuration that matches the query.
    """

    score: typing.Optional[float] = pydantic.Field(default=None)
    """
    The score of the individual result.
    """

    part_metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
    """
    The metadata for the document part.
    """

    document_metadata: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
    """
    The metadata for the document that contains the document part.
    """

    document_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    The ID of the document that contains the document part.
    """

    request_corpora_index: typing.Optional[int] = pydantic.Field(default=None)
    """
    A query request can search over multiple corpora at a time. This property
    is set to the index in the list of corpora in the original search request that this
    search result originated from.
    
    If the query request is only over one corpus, this property is 0.
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
