Debian Codegraph @

src/globus_sdk/services/search/data.py

raw
1 from __future__ import annotations
2
3 import typing as t
4
5 from globus_sdk._missing import MISSING, MissingType
6 from globus_sdk._payload import GlobusPayload
7
8
9 class SearchQueryV1(GlobusPayload):
10 """
11 A specialized dict which has helpers for creating and modifying a Search
12 Query document.
13
14 :param q: The query string. Required unless filters are used.
15 :param limit: A limit on the number of results returned in a single page
16 :param offset: An offset into the set of all results for the query
17 :param advanced: Whether to enable (``True``) or not to enable (``False``) advanced
18 parsing of query strings. The default of ``False`` is robust and guarantees that
19 the query will not error with "bad query string" errors
20 :param filters: a list of filters to apply to the query
21 :param facets: a list of facets to apply to the query
22 :param post_facet_filters: a list of filters to apply after facet
23 results are returned
24 :param boosts: a list of boosts to apply to the query
25 :param sort: a list of fields to sort results
26 :param additional_fields: additional data to include in the query document
27 """
28
29 def __init__(
30 self,
31 *,
32 q: str | MissingType = MISSING,
33 limit: int | MissingType = MISSING,
34 offset: int | MissingType = MISSING,
35 advanced: bool | MissingType = MISSING,
36 filters: list[dict[str, t.Any]] | MissingType = MISSING,
37 facets: list[dict[str, t.Any]] | MissingType = MISSING,
38 post_facet_filters: list[dict[str, t.Any]] | MissingType = MISSING,
39 boosts: list[dict[str, t.Any]] | MissingType = MISSING,
40 sort: list[dict[str, t.Any]] | MissingType = MISSING,
41 additional_fields: dict[str, t.Any] | None = None,
42 ) -> None:
43 super().__init__()
44 self["@version"] = "query#1.0.0"
45
46 self["q"] = q
47 self["limit"] = limit
48 self["offset"] = offset
49 self["advanced"] = advanced
50 self["filters"] = filters
51 self["facets"] = facets
52 self["post_facet_filters"] = post_facet_filters
53 self["boosts"] = boosts
54 self["sort"] = sort
55 self.update(additional_fields or {})
56
57
58 class SearchScrollQuery(GlobusPayload):
59 """
60 A scrolling query type, for scrolling the full result set for an index.
61
62 Scroll queries have more limited capabilities than general searches.
63 They cannot boost fields, sort, or apply facets. They can, however, still apply the
64 same filtering mechanisms which are available to normal queries.
65
66 Scrolling also differs in that it supports the use of the ``marker`` field, which is
67 used to paginate results.
68
69 :param q: The query string
70 :param limit: A limit on the number of results returned in a single page
71 :param advanced: Whether to enable (``True``) or not to enable (``False``) advanced
72 parsing of query strings. The default of ``False`` is robust and guarantees that
73 the query will not error with "bad query string" errors
74 :param marker: the marker value
75 :param additional_fields: additional data to include in the query document
76 """
77
78 def __init__(
79 self,
80 q: str | MissingType = MISSING,
81 *,
82 limit: int | MissingType = MISSING,
83 advanced: bool | MissingType = MISSING,
84 marker: str | MissingType = MISSING,
85 additional_fields: dict[str, t.Any] | None = None,
86 ) -> None:
87 super().__init__()
88 self["q"] = q
89 self["limit"] = limit
90 self["advanced"] = advanced
91 self["marker"] = marker
92 self.update(additional_fields or {})