Coverage for functions \ flipdare \ search \ core \ query \ general_query.py: 100%
18 statements
« prev ^ index » next coverage.py v7.13.0, created at 2026-05-08 12:22 +1000
« prev ^ index » next coverage.py v7.13.0, created at 2026-05-08 12:22 +1000
1#!/usr/bin/env python
2# Copyright (c) 2026 Flipdare Pty Ltd. All rights reserved.
3#
4# This file is part of Flipdare's proprietary software and contains
5# confidential and copyrighted material. Unauthorised copying,
6# modification, distribution, or use of this file is strictly
7# prohibited without prior written permission from Flipdare Pty Ltd.
8#
9# This software includes third-party components licensed under MIT,
10# BSD, and Apache 2.0 licences. See THIRD_PARTY_NOTICES for details.
11#
14from typing import override
16from typesense.types.document import SearchParameters
18from flipdare.generated.schema.search.general_document_schema import GeneralDocumentKey
19from flipdare.search.core.query.search_query import SearchQuery
20from flipdare.search.core.query_options import QueryOptions
23class GeneralQuery(SearchQuery[GeneralDocumentKey]):
24 __slots__ = ()
25 DEFAULT_OPTIONS: QueryOptions = QueryOptions.general()
27 @property
28 @override
29 def search_params(self) -> SearchParameters:
30 params = super().search_params
31 fields = self.query_by.split(",")
32 weights = ["2" if f.strip() == GeneralDocumentKey.KEYWORDS else "1" for f in fields]
33 if len(weights) > 1:
34 params["query_by_weights"] = ",".join(weights)
35 params["facet_by"] = GeneralDocumentKey.OBJ_TYPE
36 return params