(
self,
vector,
query,
weights=None,
normalization=None,
cover_density=False,
)
| 287 | output_field = FloatField() |
| 288 | |
| 289 | def __init__( |
| 290 | self, |
| 291 | vector, |
| 292 | query, |
| 293 | weights=None, |
| 294 | normalization=None, |
| 295 | cover_density=False, |
| 296 | ): |
| 297 | from .fields.array import ArrayField |
| 298 | |
| 299 | if not hasattr(vector, "resolve_expression"): |
| 300 | vector = SearchVector(vector) |
| 301 | if not hasattr(query, "resolve_expression"): |
| 302 | query = SearchQuery(query) |
| 303 | expressions = [vector, query] |
| 304 | if weights is not None: |
| 305 | if not hasattr(weights, "resolve_expression"): |
| 306 | weights = Value(weights) |
| 307 | weights = Cast(weights, ArrayField(_Float4Field())) |
| 308 | expressions = [weights, *expressions] |
| 309 | if normalization is not None: |
| 310 | if not hasattr(normalization, "resolve_expression"): |
| 311 | normalization = Value(normalization) |
| 312 | expressions.append(normalization) |
| 313 | if cover_density: |
| 314 | self.function = "ts_rank_cd" |
| 315 | super().__init__(*expressions) |
| 316 | |
| 317 | |
| 318 | class SearchHeadline(Func): |
nothing calls this directly
no test coverage detected