libQuotient
A Qt library for building matrix clients
Loading...
Searching...
No Matches
search.h
Go to the documentation of this file.
1// THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
2
3#pragma once
4
5#include <Quotient/csapi/definitions/room_event_filter.h>
6
7#include <Quotient/events/roomevent.h>
8#include <Quotient/events/stateevent.h>
9#include <Quotient/jobs/basejob.h>
10
11namespace Quotient {
12
13//! \brief Perform a server-side search.
14//!
15//! Performs a full text search across different categories.
17public:
18 // Inner data structures
19
20 //! Configures whether any context for the events
21 //! returned are included in the response.
23 //! How many events before the result are
24 //! returned. By default, this is `5`.
26
27 //! How many events after the result are
28 //! returned. By default, this is `5`.
30
31 //! Requests that the server returns the
32 //! historic profile information for the users
33 //! that sent the events that were returned.
34 //! By default, this is `false`.
36 };
37
38 //! Configuration for group.
40 //! Key that defines the group.
42 };
43
44 //! Requests that the server partitions the result set
45 //! based on the provided list of keys.
47 //! List of groups to request.
49 };
50
51 //! Mapping of category name to search criteria.
53 //! The string to search events for
55
56 //! The keys to search. Defaults to all.
58
59 //! This takes a [filter](/client-server-api/#filtering).
61
62 //! The order in which to search for results.
63 //! By default, this is `"rank"`.
65
66 //! Configures whether any context for the events
67 //! returned are included in the response.
69
70 //! Requests the server return the current state for
71 //! each room returned.
73
74 //! Requests that the server partitions the result set
75 //! based on the provided list of keys.
77 };
78
79 //! Describes which categories to search in and their criteria.
81 //! Mapping of category name to search criteria.
83 };
84
87
89 };
90
91 //! Context for result, if requested.
93 //! Pagination token for the start of the chunk
95
96 //! Pagination token for the end of the chunk
98
99 //! The historic profile information of the
100 //! users that sent the events returned.
101 //!
102 //! The key is the user ID for which
103 //! the profile belongs to.
105
106 //! Events just before the result.
108
109 //! Events just after the result.
111 };
112
113 //! The result object.
115 //! A number that describes how closely this result matches the search. Higher is closer.
116 std::optional<double> rank{};
117
118 //! The event that matched.
120
121 //! Context for result, if requested.
123 };
124
125 //! The results for a particular group value.
127 //! Token that can be used to get the next batch
128 //! of results in the group, by passing as the
129 //! `next_batch` parameter to the next call. If
130 //! this field is absent, there are no more
131 //! results in this group.
133
134 //! Key that can be used to order different
135 //! groups.
137
138 //! Which results are in this group.
140 };
141
142 //! Mapping of category name to search criteria.
144 //! An approximate count of the total number of results found.
146
147 //! List of words which should be highlighted, useful for stemming which may change the
148 //! query terms.
150
151 //! List of results in the requested order.
153
154 //! The current state for every room in the results.
155 //! This is included if the request had the
156 //! `include_state` key set with a value of `true`.
157 //!
158 //! The key is the room ID for which the `State
159 //! Event` array belongs to.
161
162 //! Any groups that were requested.
163 //!
164 //! The outer `string` key is the group key requested (eg: `room_id`
165 //! or `sender`). The inner `string` key is the grouped value (eg:
166 //! a room's ID or a user's ID).
168
169 //! Token that can be used to get the next batch of
170 //! results, by passing as the `next_batch` parameter to
171 //! the next call. If this field is absent, there are no
172 //! more results.
174 };
175
176 //! Describes which categories to search in and their criteria.
178 //! Mapping of category name to search criteria.
180 };
181
182 // Construction/destruction
183
184 //! \param searchCategories
185 //! Describes which categories to search in and their criteria.
186 //!
187 //! \param nextBatch
188 //! The point to return events from. If given, this should be a
189 //! `next_batch` result from a previous call to this endpoint.
191
192 // Result properties
193
194 //! Describes which categories to search in and their criteria.
196 {
197 return loadFromJson<ResultCategories>("search_categories"_L1);
198 }
199};
200
201inline auto collectResponse(const SearchJob* job) { return job->searchCategories(); }
202
203template <>
206 {
207 addParam<IfNotEmpty>(jo, "before_limit"_L1, pod.beforeLimit);
208 addParam<IfNotEmpty>(jo, "after_limit"_L1, pod.afterLimit);
209 addParam<IfNotEmpty>(jo, "include_profile"_L1, pod.includeProfile);
210 }
211};
212
213template <>
215 static void dumpTo(QJsonObject& jo, const SearchJob::Group& pod)
216 {
217 addParam<IfNotEmpty>(jo, "key"_L1, pod.key);
218 }
219};
220
221template <>
223 static void dumpTo(QJsonObject& jo, const SearchJob::Groupings& pod)
224 {
225 addParam<IfNotEmpty>(jo, "group_by"_L1, pod.groupBy);
226 }
227};
228
229template <>
231 static void dumpTo(QJsonObject& jo, const SearchJob::RoomEventsCriteria& pod)
232 {
233 addParam(jo, "search_term"_L1, pod.searchTerm);
234 addParam<IfNotEmpty>(jo, "keys"_L1, pod.keys);
235 addParam<IfNotEmpty>(jo, "filter"_L1, pod.filter);
236 addParam<IfNotEmpty>(jo, "order_by"_L1, pod.orderBy);
237 addParam<IfNotEmpty>(jo, "event_context"_L1, pod.eventContext);
238 addParam<IfNotEmpty>(jo, "include_state"_L1, pod.includeState);
239 addParam<IfNotEmpty>(jo, "groupings"_L1, pod.groupings);
240 }
241};
242
243template <>
245 static void dumpTo(QJsonObject& jo, const SearchJob::Categories& pod)
246 {
247 addParam<IfNotEmpty>(jo, "room_events"_L1, pod.roomEvents);
248 }
249};
250
251template <>
253 static void fillFrom(const QJsonObject& jo, SearchJob::UserProfile& result)
254 {
255 fillFromJson(jo.value("displayname"_L1), result.displayname);
256 fillFromJson(jo.value("avatar_url"_L1), result.avatarUrl);
257 }
258};
259
260template <>
262 static void fillFrom(const QJsonObject& jo, SearchJob::EventContext& result)
263 {
264 fillFromJson(jo.value("start"_L1), result.begin);
265 fillFromJson(jo.value("end"_L1), result.end);
266 fillFromJson(jo.value("profile_info"_L1), result.profileInfo);
267 fillFromJson(jo.value("events_before"_L1), result.eventsBefore);
268 fillFromJson(jo.value("events_after"_L1), result.eventsAfter);
269 }
270};
271
272template <>
274 static void fillFrom(const QJsonObject& jo, SearchJob::Result& result)
275 {
276 fillFromJson(jo.value("rank"_L1), result.rank);
277 fillFromJson(jo.value("result"_L1), result.result);
278 fillFromJson(jo.value("context"_L1), result.context);
279 }
280};
281
282template <>
284 static void fillFrom(const QJsonObject& jo, SearchJob::GroupValue& result)
285 {
286 fillFromJson(jo.value("next_batch"_L1), result.nextBatch);
287 fillFromJson(jo.value("order"_L1), result.order);
288 fillFromJson(jo.value("results"_L1), result.results);
289 }
290};
291
292template <>
295 {
296 fillFromJson(jo.value("count"_L1), result.count);
297 fillFromJson(jo.value("highlights"_L1), result.highlights);
298 fillFromJson(jo.value("results"_L1), result.results);
299 fillFromJson(jo.value("state"_L1), result.state);
300 fillFromJson(jo.value("groups"_L1), result.groups);
301 fillFromJson(jo.value("next_batch"_L1), result.nextBatch);
302 }
303};
304
305template <>
308 {
309 fillFromJson(jo.value("room_events"_L1), result.roomEvents);
310 }
311};
312
313} // namespace Quotient
Perform a server-side search.
Definition search.h:16
auto collectResponse(const GetAccountDataJob *job)
#define QUOTIENT_API