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

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from .image_metadata import ImageMetadata
from .table import Table


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.
    """

    table: typing.Optional[Table] = pydantic.Field(default=None)
    """
    The table that the document part is from.
    """

    image: typing.Optional[ImageMetadata] = pydantic.Field(default=None)
    """
    The image that the document part is from.
    """

    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
