$darkmode
Qore ElasticSearchDataProvider Module Reference 1.0
ElasticSearchRecordIterator.qc.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
29
30public:
31
32private:
35
37 string name;
38
40 hash<auto> index;
41
43 hash<string, DataProvider::AbstractDataField> record_type;
44
47
49 const MatchOptions = ("operator",);
50
51public:
52
54
62 hash<string, DataProvider::AbstractDataField> record_type, *hash<auto> where_cond,
63 *hash<auto> search_options) {
64 self.rest = rest;
65 self.name = name;
66 self.index = index;
67 self.record_type = record_type;
68
69 string uri = sprintf("%s/_search", name);
70
71 if (search_options);
72
73
74 // make query
75 *hash<auto> query_body = makeQuery(where_cond, search_options);
76 hash<auto> info;
77 try {
78 i = new ListHashIterator((map $1{"_id", "_score"} + $1._source,
79 rest.post(uri, query_body, \info).body.hits.hits));
80 } catch (hash<ExceptionInfo> ex) {
81 // ensure that any error response body is included in the exception
82 hash<auto> ex_arg = {
83 "query": query_body,
84 } + info{"response-code", "response-body"};
85 rethrow ex.err, ex.desc, ex_arg;
86 }
87 }
88
90
93 bool valid();
94
95
97
103 bool next();
104
105
107
109 hash<auto> getValue();
110
111
113
119 auto memberGate(string key);
120
121
123 *hash<auto> makeQuery(*hash<auto> where_cond, *hash<auto> search_options);
124
125
127
129 *hash<string, DataProvider::AbstractDataField> getRecordType();
130
131};
132};
Defines the record iterator class for Table-based iterators.
Definition: ElasticSearchRecordIterator.qc.dox.h:28
hash< auto > index
Index hash.
Definition: ElasticSearchRecordIterator.qc.dox.h:40
bool valid()
Returns True if the iterator is valid.
*hash< auto > makeQuery(*hash< auto > where_cond, *hash< auto > search_options)
Returns the query body.
auto memberGate(string key)
Returns the value of the given field in the current row, if the iterator is valid.
string name
current index name
Definition: ElasticSearchRecordIterator.qc.dox.h:37
hash< auto > getValue()
Returns a single record if the iterator is valid.
RestClient::RestClient rest
The REST client object for API calls.
Definition: ElasticSearchRecordIterator.qc.dox.h:34
constructor(RestClient::RestClient rest, string name, hash< auto > index, hash< string, DataProvider::AbstractDataField > record_type, *hash< auto > where_cond, *hash< auto > search_options)
creates the iterator
Definition: ElasticSearchRecordIterator.qc.dox.h:61
hash< string, DataProvider::AbstractDataField > record_type
The record type for the object.
Definition: ElasticSearchRecordIterator.qc.dox.h:43
const MatchOptions
Query match options.
Definition: ElasticSearchRecordIterator.qc.dox.h:49
bool next()
Increments the row pointer when retrieving rows from a select statement.
*hash< string, DataProvider::AbstractDataField > getRecordType()
Returns the record description, if available.
Qore::ListHashIterator i
record iterator
Definition: ElasticSearchRecordIterator.qc.dox.h:46
hash< auto > post(string path, auto body, *reference< hash< auto > > info, *hash< auto > hdr)
string sprintf(string fmt,...)
Qore ElasticSearchDataProvider module definition.
Definition: ElasticSearchAcknowledgedDataType.qc.dox.h:26