Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
827 changes: 367 additions & 460 deletions src/monggregate/search/collectors/facet.py

Large diffs are not rendered by default.

36 changes: 27 additions & 9 deletions src/monggregate/search/commons/highlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,41 @@

from monggregate.base import BaseModel, pyd

# TODO : Check if those are missing an expression property <VM, 21/04/2024>

class HighlightOptions(BaseModel):
"""Class defining the highlighting parameters."""

path : str
max_chars_to_examine : int = pyd.Field(500000, alias="maxCharsToExamine")
max_num_passages : int = pyd.Field(5, alias="maxNumPassages")
path: str
max_chars_to_examine: int = pyd.Field(500000, alias="maxCharsToExamine")
max_num_passages: int = pyd.Field(5, alias="maxNumPassages")

@property
def expression(self) -> str:
"""Return the expression for the highlighting."""

return self.model_dump(by_alias=True)


class HighlightText(BaseModel):
"""Highlighted text."""

value : str
type : Literal["hit", "text"]
value: str
type: Literal["hit", "text"]

@property
def expression(self) -> str:
"""Return the expression for the highlighting."""
return self.model_dump(by_alias=True)


class HightlightOutput(BaseModel):
"""Class defining the highlights appear in a search query results."""

path : str
texts : list[HighlightText]
score : float
path: str
texts: list[HighlightText]
score: float

@property
def expression(self) -> str:
"""Return the expression for the highlighting."""
return self.model_dump(by_alias=True)
Loading