Qore ElasticSearchDataProvider Module Reference 1.0
Loading...
Searching...
No Matches
ElasticSearchIndexTableDataProvider.qc.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
28
39
40public:
43
45 string name;
46
48 hash<auto> index;
49
51 const ProviderInfo = <DataProviderInfo>{
52 "desc": "ElasticSearch index table data provider; provdes table-like access to an ElasticSearch index; "
53 "fields returned in searches are document properties, plus the special `_id` (document ID) and "
54 "`_score` (query match score) values, which are read-only.\n\n"
55 "Updating and deleting can be performed, but the 'where clause hash` must contain only a single "
56 "`_id` key to identify the document by its ID.\n\n"
57 "Searches are performed with `match`; for more flexible searching, use the index search API data "
58 "provider, `index/search`",
59 "type": "ElasticSearchIndexTableDataProvider",
61 "has_record": True,
62 "supports_read": True,
63 "supports_native_search": True,
64 "supports_update": True,
65 "supports_delete": True,
66 "supports_create": True,
67 "create_options": {
68 "if_seq_no": <DataProviderOptionInfo>{
69 "type": AbstractDataProviderTypeMap."int",
70 "desc": "Only perform the operation if the document has this sequence number",
71 },
72 "if_primary_term": <DataProviderOptionInfo>{
73 "type": AbstractDataProviderTypeMap."int",
74 "desc": "Only perform the operation if the document has this primary term",
75 },
76 "op_type": <DataProviderOptionInfo>{
77 "type": AbstractDataProviderTypeMap."string",
78 "desc": "Set to create to only index the document if it does not already exist (put if absent). If a "
79 "document with the specified `_id` already exists, the indexing operation will fail. Same as "
80 "using the `<index>/_create` endpoint. Valid values: `index`, `create`. If document id is "
81 "specified, it defaults to `index`. Otherwise, it defaults to `create`",
82 },
83 "pipeline": <DataProviderOptionInfo>{
84 "type": AbstractDataProviderTypeMap."string",
85 "desc": "ID of the pipeline to use to preprocess incoming documents. If the index has a default "
86 "ingest pipeline specified, then setting the value to _none disables the default ingest pipeline "
87 "for this request. If a final pipeline is configured it will always run, regardless of the value "
88 "of this parameter",
89 },
90 "refresh": <DataProviderOptionInfo>{
91 "type": AbstractDataProviderTypeMap."string",
92 "desc": "If `true`, Elasticsearch refreshes the affected shards to make this operation visible to "
93 "search, if `wait_for` then wait for a refresh to make this operation visible to search, if "
94 "`false` do nothing with refreshes. Valid values: `true`, `false`, `wait_for`",
95 },
96 "routing": <DataProviderOptionInfo>{
97 "type": AbstractDataProviderTypeMap."string",
98 "desc": "Custom value used to route operations to a specific shard",
99 },
100 "timeout": <DataProviderOptionInfo>{
101 "type": AbstractDataProviderTypeMap."string",
102 "desc": "Period to wait for a response (ex: `1m`). If no response is received before the "
103 "timeout expires, the request fails and returns an error",
104 },
105 "version": <DataProviderOptionInfo>{
106 "type": AbstractDataProviderTypeMap."int",
107 "desc": "Explicit version number for concurrency control. The specified version must match the "
108 "current version of the document for the request to succeed",
109 },
110 "version_type": <DataProviderOptionInfo>{
111 "type": AbstractDataProviderTypeMap."string",
112 "desc": "Specific version type: `external`, `external_gte`",
113 },
114 "wait_for_active_shards": <DataProviderOptionInfo>{
115 "type": AbstractDataProviderTypeMap."string",
116 "desc": "The number of shard copies that must be active before proceeding with the operation. Set to "
117 "`all` or any positive integer up to the total number of shards in the index (number_of_replicas+1)",
118 },
119 "require_alias": <DataProviderOptionInfo>{
121 "desc": "If `true`, the destination must be an index alias",
122 },
123 },
124 "search_options": {
125 "if_seq_no": <DataProviderOptionInfo>{
126 "type": AbstractDataProviderTypeMap."int",
127 "desc": "Only perform the operation if the document has this sequence number\n"
128 "(update only)",
129 },
130 "if_primary_term": <DataProviderOptionInfo>{
131 "type": AbstractDataProviderTypeMap."int",
132 "desc": "Only perform the operation if the document has this primary term\n"
133 "(update only)",
134 },
135 "lang": <DataProviderOptionInfo>{
136 "type": AbstractDataProviderTypeMap."string",
137 "desc": "The script language\n"
138 "(update only)",
139 },
140 "operator": <DataProviderOptionInfo>{
141 "type": AbstractDataProviderTypeMap."string",
142 "desc": "Boolean logic used to interpret text in the query value. Valid values are:\n"
143 "- `or` (Default): For example, a query value of `capital of Hungary` is interpreted as "
144 "`capital OR of OR Hungary`\n"
145 "- `and`: For example, a query value of `capital of Hungary` is interpreted as "
146 "`capital AND of AND Hungary`\n"
147 "(search only)",
148 "allowed_values": (
149 <AllowedValueInfo>{
150 "value": "or",
151 "desc": "Or logic - any terms match (default)",
152 },
153 <AllowedValueInfo>{
154 "value": "and",
155 "desc": "And logic - all terms must match",
156 }
157 ),
158 },
159 "require_alias": <DataProviderOptionInfo>{
161 "desc": "If `true`, the destination must be an index alias\n"
162 "(update only)",
163 },
164 "refresh": <DataProviderOptionInfo>{
165 "type": AbstractDataProviderTypeMap."string",
166 "desc": "If `true`, Elasticsearch refreshes the affected shards to make this operation visible to "
167 "search, if `wait_for` then wait for a refresh to make this operation visible to search, if "
168 "`false` do nothing with refreshes. Valid values: `true`, `false`, `wait_for`\n"
169 "(update only)",
170 },
171 "retry_on_conflict": <DataProviderOptionInfo>{
172 "type": AbstractDataProviderTypeMap."int",
173 "desc": "Specify how many times should the operation be retried when a conflict occurs\n"
174 "(update only)",
175 },
176 "routing": <DataProviderOptionInfo>{
177 "type": AbstractDataProviderTypeMap."string",
178 "desc": "Custom value used to route operations to a specific shard\n"
179 "(update only)",
180 },
181 "_source": <DataProviderOptionInfo>{
182 "type": AbstractDataProviderTypeMap."string",
183 "desc": "Set to `false` to disable source retrieval (default: `true`). You can also specify a "
184 "comma-separated list of the fields you want to retrieve\n"
185 "(update only)",
186 },
187 "_source_excludes": <DataProviderOptionInfo>{
188 "type": AbstractDataProviderTypeMap."string",
189 "desc": "Specify the source fields you want to exclude\n"
190 "(update only)",
191 },
192 "_source_includes": <DataProviderOptionInfo>{
193 "type": AbstractDataProviderTypeMap."string",
194 "desc": "Specify the source fields you want to exclude\n"
195 "(update only)",
196 },
197 "timeout": <DataProviderOptionInfo>{
198 "type": AbstractDataProviderTypeMap."string",
199 "desc": "Period to wait for a response (ex: `1m` = 1 minute). If no response is received before "
200 "the timeout expires, the request fails and returns an error",
201 },
202 "version": <DataProviderOptionInfo>{
203 "type": AbstractDataProviderTypeMap."string",
204 "desc": "",
205 },
206 "wait_for_active_shards": <DataProviderOptionInfo>{
207 "type": AbstractDataProviderTypeMap."string",
208 "desc": "The number of shard copies that must be active before proceeding with the operation. "
209 "Set to `all` or any positive integer up to the total number of shards in the index "
210 "(number_of_replicas+1)\n"
211 "(update only)",
212 },
213 },
214 };
215
217 const ProviderSummaryInfo = cast<hash<DataProviderSummaryInfo>>(ProviderInfo{
218 AbstractDataProvider::DataProviderSummaryInfoKeys
219 });
220
222 const TypeMap = {
223 "binary": AbstractDataProviderTypeMap."base64binary",
224
225 "boolean": AbstractDataProviderTypeMap."boolean",
226
227 "keyword": AbstractDataProviderTypeMap."string",
228 "constant_keyword": AbstractDataProviderTypeMap."string",
229 "wildcard": AbstractDataProviderTypeMap."string",
230
231 "ip": AbstractDataProviderTypeMap."string",
232 "version": AbstractDataProviderTypeMap."string",
233 "mumur3": AbstractDataProviderTypeMap."string",
234
235 "text": AbstractDataProviderTypeMap."string",
236 "match_only_text": AbstractDataProviderTypeMap."string",
237
238 "byte": AbstractDataProviderTypeMap."int",
239 "short": AbstractDataProviderTypeMap."int",
240 "integer": AbstractDataProviderTypeMap."int",
241 "long": AbstractDataProviderTypeMap."int",
242
243 "unsigned_long": AbstractDataProviderTypeMap."number",
244
245 "date": AbstractDataProviderTypeMap."date",
246 // NOTE: lossy conversion here; Qore only supports microsecond resolution
247 "date_nanos": AbstractDataProviderTypeMap."date",
248
249 "double": AbstractDataProviderTypeMap."float",
250 "float": AbstractDataProviderTypeMap."float",
251 "half_float": AbstractDataProviderTypeMap."float",
252 "scaled_float": AbstractDataProviderTypeMap."float",
253
254 "object": AbstractDataProviderTypeMap."hash",
255 "flattened": AbstractDataProviderTypeMap."hash",
256
257 "nested": AbstractDataProviderTypeMap."list",
258 };
259
261 const SearchQueryOptions = ("timeout",);
262
263protected:
265 hash<string, AbstractDataField> record_type = {
266 "_id": new QoreDataField("_id", "the document ID", AbstractDataProviderTypeMap."softstring"),
267 "_score": new QoreDataField("_score", "the score for the match (read-only)",
268 AbstractDataProviderTypeMap."float"),
269 };
270
271public:
272
275
276
278 string getName();
279
280
282 *string getDesc();
283
284
286
292 *hash<auto> search_options) {
293 return new ElasticSearchRecordIterator(rest, name, index, record_type, where_cond, search_options);
294 }
295
297
306protected:
307 int updateRecordsImpl(hash<auto> set, *hash<auto> where_cond, *hash<auto> search_options);
308public:
309
310
320protected:
321 int deleteRecordsImpl(*hash<auto> where_cond, *hash<auto> search_options);
322public:
323
324
326
334protected:
335 *hash<auto> createRecordImpl(hash<auto> rec, *hash<auto> create_options);
336public:
337
338
340 hash<DataProvider::DataProviderInfo> getStaticInfoImpl();
341
342
345
346
348 static string getQueryOptions(string uri, hash<auto> search_options, list<string> query_args);
349
351 private string getDocUriPath(string uri_str, *hash<auto> where_cond, string action, *hash<auto> search_options,
352 *list<string> query_args) {
353 if (!where_cond._id.val());
354
355 if (where_cond._id.typeCode() != NT_STRING);
356
357 if (where_cond.size() > 1);
358
359 string rv = sprintf("%s/%s/%s", name, uri_str, where_cond._id);
360 return search_options && query_args ? getQueryOptions(rv, search_options, query_args) : rv;
361 }
362
364protected:
366public:
367
368
369protected:
370 *hash<string, DataProvider::AbstractDataField> getRecordTypeImpl(*hash<auto> search_options);
371public:
372
373};
374};
const ConstructorOptions
Constructor options.
Definition: ElasticSearchDataProvider.qc.dox.h:64
This class exposes ElasticSearch indices as record-based data providers.
Definition: ElasticSearchIndexTableDataProvider.qc.dox.h:38
const ProviderSummaryInfo
Provider summary info.
Definition: ElasticSearchIndexTableDataProvider.qc.dox.h:217
const ProviderInfo
Provider info.
Definition: ElasticSearchIndexTableDataProvider.qc.dox.h:51
static string getQueryOptions(string uri, hash< auto > search_options, list< string > query_args)
Returns a URI path with query options.
int deleteRecordsImpl(*hash< auto > where_cond, *hash< auto > search_options)
DataProvider::AbstractDataProviderType getTypeForProperty(string name, hash< auto > prop)
Returns a data type for a property.
private string getDocUriPath(string uri_str, *hash< auto > where_cond, string action, *hash< auto > search_options, *list< string > query_args)
Makes sure that the where_cond is only the _id field.
Definition: ElasticSearchIndexTableDataProvider.qc.dox.h:351
const SearchQueryOptions
Search query options.
Definition: ElasticSearchIndexTableDataProvider.qc.dox.h:261
constructor(RestClient::RestClient rest, string name, hash< auto > index)
Creates the object from a REST connection.
int updateRecordsImpl(hash< auto > set, *hash< auto > where_cond, *hash< auto > search_options)
Updates a single document in the index.
hash< DataProvider::DataProviderInfo > getStaticInfoImpl()
Returns data provider static info.
hash< auto > index
Index hash.
Definition: ElasticSearchIndexTableDataProvider.qc.dox.h:48
hash< string, AbstractDataField > record_type
The record type for the object.
Definition: ElasticSearchIndexTableDataProvider.qc.dox.h:265
RestClient::RestClient rest
REST client connection.
Definition: ElasticSearchIndexTableDataProvider.qc.dox.h:42
private DataProvider::AbstractDataProviderRecordIterator searchRecordsImpl(*hash< auto > where_cond, *hash< auto > search_options)
Returns an iterator for zero or more records matching the search options.
Definition: ElasticSearchIndexTableDataProvider.qc.dox.h:291
*hash< auto > createRecordImpl(hash< auto > rec, *hash< auto > create_options)
Writes the given record to the data provider.
string name
Current index name.
Definition: ElasticSearchIndexTableDataProvider.qc.dox.h:45
*string getDesc()
Returns the data provider description.
const TypeMap
ElasticSearch property types to data types.
Definition: ElasticSearchIndexTableDataProvider.qc.dox.h:222
Defines the record iterator class for Table-based iterators.
Definition: ElasticSearchRecordIterator.qc.dox.h:28
Qore ElasticSearchDataProvider module definition.
Definition: ElasticSearchAcknowledgedDataType.qc.dox.h:26
const SoftBoolDataProviderStringType
Boolean data provider string type for query parameters.
Definition: ElasticSearchDataProvider.qc.dox.h:137