Skip to content

Commit ff689af

Browse files
committed
Add resource APIs and expanded search, document, and system endpoints.
1 parent 1fe601c commit ff689af

13 files changed

Lines changed: 956 additions & 1 deletion

File tree

include/hlquery/client.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "collections.h"
2020
#include "documents.h"
2121
#include "request.h"
22+
#include "resources.h"
2223
#include "response.h"
2324
#include "search.h"
2425
#include "system.h"
@@ -37,21 +38,40 @@ class Client
3738
void clearAuth();
3839

3940
std::shared_ptr<System> system();
41+
std::shared_ptr<Aliases> aliases();
42+
std::shared_ptr<Overrides> overrides();
43+
std::shared_ptr<Synonyms> synonyms();
44+
std::shared_ptr<Stopwords> stopwords();
45+
std::shared_ptr<Keys> keys();
46+
std::shared_ptr<Users> users();
47+
std::shared_ptr<Modules> modules();
48+
std::shared_ptr<Presets> presets();
49+
std::shared_ptr<Analytics> analytics();
4050

4151
/* System APIs */
4252

4353
Response health();
54+
Response ready();
4455
Response status();
56+
Response query();
4557
Response startup();
4658
Response bootStatus();
4759
Response stats();
4860
Response metrics();
4961
Response metricsJson();
62+
Response metricsHistory();
5063
Response connections();
5164
Response rocksdb();
5265
Response rocksdbInternal();
5366
Response docTotal();
5467
Response etc();
68+
Response searchConfig();
69+
Response cache();
70+
Response updateCounters(const std::map<std::string, std::string>& params = {});
71+
Response updateCountersPost(const nlohmann::json& body = nlohmann::json::object());
72+
Response debugCounters();
73+
Response repair(const std::map<std::string, std::string>& params = {});
74+
Response repairPost(const nlohmann::json& body = nlohmann::json::object());
5575
Response info();
5676
Response flush();
5777
Response ping();
@@ -74,20 +94,27 @@ class Client
7494
Response listCollectionsDistributed();
7595
Response getCollection(const std::string& name);
7696
Response getCollectionFields(const std::string& name);
97+
Response getCollectionLanguage(const std::string& name);
7798
Response copyCollection(const std::string& source_name, const std::string& target_name, int batch_size = 500);
7899

79100
/* Documents API */
80101

81102
std::shared_ptr<Documents> documents();
82103
Response listDocuments(const std::string& collection_name, const std::map<std::string, std::string>& params = {});
83104
Response getDocument(const std::string& collection_name, const std::string& document_id);
105+
Response exportDocuments(const std::string& collection_name, const std::map<std::string, std::string>& params = {});
106+
Response facetCounts(const std::string& collection_name, const std::map<std::string, std::string>& params = {});
107+
Response maybe(const std::string& collection_name, const std::map<std::string, std::string>& params = {});
108+
Response documentContext(const std::string& collection_name, const std::string& document_id,
109+
const std::map<std::string, std::string>& params = {});
84110

85111
/* Search API */
86112

87113
[[deprecated("Use client.collections()->search(...) for collection-scoped searches.")]]
88114
std::shared_ptr<Search> searchApi();
89115
[[deprecated("Use client.collections()->search(...) for collection-scoped searches.")]]
90116
Response search(const std::string& collection_name, const std::map<std::string, std::string>& params = {});
117+
Response searchPost(const std::string& collection_name, const nlohmann::json& body);
91118
[[deprecated("Use client.sql(collection_name, sql, ...) for collection-scoped SQL searches.")]]
92119
Response sqlSearch(const std::string& collection_name, const std::string& sql,
93120
const std::map<std::string, std::string>& params = {});
@@ -97,8 +124,12 @@ class Client
97124
Response execSql(const std::string& sql);
98125
[[deprecated("Use client.collections()->vectorSearch(...) for collection-scoped vector searches.")]]
99126
Response vectorSearch(const std::string& collection_name, const std::map<std::string, std::string>& params = {});
127+
Response vectorSearchPost(const std::string& collection_name, const nlohmann::json& body);
100128
Response multiSearch(const std::vector<nlohmann::json>& searches);
129+
Response multiSearch(const std::map<std::string, std::string>& params);
101130
MultiSearchResult multiSearchStructured(const std::vector<nlohmann::json>& searches);
131+
Response globalSearch(const std::map<std::string, std::string>& params = {});
132+
Response globalSearchPost(const nlohmann::json& body);
102133

103134
/* Execute arbitrary request */
104135

@@ -113,6 +144,15 @@ class Client
113144
std::shared_ptr<Documents> documents_;
114145
std::shared_ptr<Search> search_;
115146
std::shared_ptr<System> system_;
147+
std::shared_ptr<Aliases> aliases_;
148+
std::shared_ptr<Overrides> overrides_;
149+
std::shared_ptr<Synonyms> synonyms_;
150+
std::shared_ptr<Stopwords> stopwords_;
151+
std::shared_ptr<Keys> keys_;
152+
std::shared_ptr<Users> users_;
153+
std::shared_ptr<Modules> modules_;
154+
std::shared_ptr<Presets> presets_;
155+
std::shared_ptr<Analytics> analytics_;
116156
};
117157

118158
}

include/hlquery/collections.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,14 @@ class Collections
3636
Response remove(const std::string& name);
3737
Response update(const std::string& name, const nlohmann::json& schema);
3838
Response getFields(const std::string& name);
39+
Response getLanguage(const std::string& name);
3940
Response search(const std::string& name, const std::map<std::string, std::string>& params = {});
41+
Response searchPost(const std::string& name, const nlohmann::json& body);
4042
SearchResult searchStructured(const std::string& name, const std::map<std::string, std::string>& params = {});
4143
Response sql(const std::string& name, const std::string& sql,
4244
const std::map<std::string, std::string>& params = {});
4345
Response vectorSearch(const std::string& name, const std::map<std::string, std::string>& params = {});
46+
Response vectorSearchPost(const std::string& name, const nlohmann::json& body);
4447
SearchResult vectorSearchStructured(const std::string& name, const std::map<std::string, std::string>& params = {});
4548

4649
/* Utility helpers */

include/hlquery/documents.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ class Documents
3636
Response remove(const std::string& collection_name, const std::string& document_id);
3737
Response importDocuments(const std::string& collection_name, const std::vector<nlohmann::json>& documents);
3838
Response deleteByFilter(const std::string& collection_name, const std::string& filter);
39+
Response updateByQuery(const std::string& collection_name, const nlohmann::json& body);
40+
Response deleteByQuery(const std::string& collection_name, const nlohmann::json& body);
41+
Response facetCounts(const std::string& collection_name, const std::map<std::string, std::string>& params = {});
42+
Response exportDocuments(const std::string& collection_name, const std::map<std::string, std::string>& params = {});
43+
Response maybe(const std::string& collection_name, const std::map<std::string, std::string>& params = {});
44+
Response context(const std::string& collection_name, const std::string& document_id,
45+
const std::map<std::string, std::string>& params = {});
3946

4047
private:
4148

include/hlquery/resources.h

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
/*
2+
* hlquery C++ Client - Resource APIs
3+
* https://www.hlquery.com
4+
*
5+
* Copyright (C) 2021-2026, Carlos F. Ferry <carlos.ferry@gmail.com>
6+
*
7+
* This file is part of hlquery, released under the BSD License version 3.
8+
* You are free to redistribute and/or modify this software
9+
* under the terms of the BSD License.
10+
* For more details, please visit: https://docs.hlquery.com
11+
*/
12+
13+
#pragma once
14+
15+
#include <map>
16+
#include <memory>
17+
#include <string>
18+
19+
#include "request.h"
20+
#include "response.h"
21+
22+
namespace hlquery
23+
{
24+
25+
class Aliases
26+
{
27+
public:
28+
29+
explicit Aliases(std::shared_ptr<Request> request);
30+
31+
Response list();
32+
Response list(const std::string& collection_name);
33+
Response get(const std::string& name);
34+
Response upsert(const std::string& name, const nlohmann::json& body);
35+
Response create(const std::string& name, const nlohmann::json& body);
36+
Response update(const std::string& name, const nlohmann::json& body);
37+
Response remove(const std::string& name);
38+
39+
private:
40+
41+
std::shared_ptr<Request> request_;
42+
};
43+
44+
class Synonyms
45+
{
46+
public:
47+
48+
explicit Synonyms(std::shared_ptr<Request> request);
49+
50+
Response list(const std::string& collection_name);
51+
Response get(const std::string& collection_name, const std::string& id);
52+
Response upsert(const std::string& collection_name, const std::string& id, const nlohmann::json& body);
53+
Response create(const std::string& collection_name, const std::string& id, const nlohmann::json& body);
54+
Response update(const std::string& collection_name, const std::string& id, const nlohmann::json& body);
55+
Response remove(const std::string& collection_name, const std::string& id);
56+
Response listAll();
57+
Response listGlobal();
58+
Response getGlobal(const std::string& id);
59+
Response upsertGlobal(const std::string& id, const nlohmann::json& body);
60+
Response createGlobal(const std::string& id, const nlohmann::json& body);
61+
Response updateGlobal(const std::string& id, const nlohmann::json& body);
62+
Response removeGlobal(const std::string& id);
63+
64+
private:
65+
66+
std::shared_ptr<Request> request_;
67+
};
68+
69+
class Stopwords
70+
{
71+
public:
72+
73+
explicit Stopwords(std::shared_ptr<Request> request);
74+
75+
Response list(const std::string& collection_name);
76+
Response create(const std::string& collection_name, const nlohmann::json& body);
77+
Response remove(const std::string& collection_name, const std::string& word);
78+
Response listAll();
79+
Response listGlobal();
80+
Response createGlobal(const nlohmann::json& body);
81+
Response removeGlobal(const std::string& word);
82+
83+
private:
84+
85+
std::shared_ptr<Request> request_;
86+
};
87+
88+
class Overrides
89+
{
90+
public:
91+
92+
explicit Overrides(std::shared_ptr<Request> request);
93+
94+
Response list(const std::string& collection_name);
95+
Response get(const std::string& collection_name, const std::string& id);
96+
Response upsert(const std::string& collection_name, const std::string& id, const nlohmann::json& body);
97+
Response create(const std::string& collection_name, const std::string& id, const nlohmann::json& body);
98+
Response update(const std::string& collection_name, const std::string& id, const nlohmann::json& body);
99+
Response remove(const std::string& collection_name, const std::string& id);
100+
101+
private:
102+
103+
std::shared_ptr<Request> request_;
104+
};
105+
106+
class Keys
107+
{
108+
public:
109+
110+
explicit Keys(std::shared_ptr<Request> request);
111+
112+
Response list();
113+
Response get(const std::string& id);
114+
Response create(const nlohmann::json& body);
115+
Response update(const std::string& id, const nlohmann::json& body);
116+
Response remove(const std::string& id);
117+
118+
private:
119+
120+
std::shared_ptr<Request> request_;
121+
};
122+
123+
class Users
124+
{
125+
public:
126+
127+
explicit Users(std::shared_ptr<Request> request);
128+
129+
Response list();
130+
Response get(const std::string& id);
131+
Response create(const nlohmann::json& body);
132+
Response update(const std::string& id, const nlohmann::json& body);
133+
Response remove(const std::string& id);
134+
135+
private:
136+
137+
std::shared_ptr<Request> request_;
138+
};
139+
140+
class Modules
141+
{
142+
public:
143+
144+
explicit Modules(std::shared_ptr<Request> request);
145+
146+
Response list();
147+
Response syntax(const std::string& name);
148+
Response load(const std::string& name, const nlohmann::json& body = nlohmann::json::object());
149+
Response unload(const std::string& name, const nlohmann::json& body = nlohmann::json::object());
150+
Response call(const std::string& method, const std::string& path, const nlohmann::json& body = nullptr,
151+
const std::map<std::string, std::string>& query_params = {});
152+
153+
private:
154+
155+
std::shared_ptr<Request> request_;
156+
};
157+
158+
class Presets
159+
{
160+
public:
161+
162+
explicit Presets(std::shared_ptr<Request> request);
163+
164+
Response list();
165+
Response get(const std::string& name);
166+
Response upsert(const std::string& name, const nlohmann::json& body);
167+
Response create(const std::string& name, const nlohmann::json& body);
168+
Response update(const std::string& name, const nlohmann::json& body);
169+
Response remove(const std::string& name);
170+
171+
private:
172+
173+
std::shared_ptr<Request> request_;
174+
};
175+
176+
class Analytics
177+
{
178+
public:
179+
180+
explicit Analytics(std::shared_ptr<Request> request);
181+
182+
Response click(const nlohmann::json& body);
183+
184+
private:
185+
186+
std::shared_ptr<Request> request_;
187+
};
188+
189+
}

include/hlquery/search.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,15 @@ class Search
3232
Search(std::shared_ptr<Request> request, std::shared_ptr<Collections> collections);
3333

3434
Response search(const std::string& collection_name, const std::map<std::string, std::string>& params = {});
35+
Response searchPost(const std::string& collection_name, const nlohmann::json& body);
3536
Response sql(const std::string& collection_name, const std::string& sql,
3637
const std::map<std::string, std::string>& params = {});
3738
Response multiSearch(const std::vector<nlohmann::json>& searches);
39+
Response multiSearch(const std::map<std::string, std::string>& params);
40+
Response globalSearch(const std::map<std::string, std::string>& params = {});
41+
Response globalSearchPost(const nlohmann::json& body);
3842
Response vectorSearch(const std::string& collection_name, const std::map<std::string, std::string>& params = {});
43+
Response vectorSearchPost(const std::string& collection_name, const nlohmann::json& body);
3944

4045
SearchResult searchStructured(const std::string& collection_name, const std::map<std::string, std::string>& params = {});
4146
MultiSearchResult multiSearchStructured(const std::vector<nlohmann::json>& searches);

include/hlquery/system.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,29 @@ class System
2929
explicit System(std::shared_ptr<Request> request);
3030

3131
Response health();
32+
Response ready();
3233
Response status();
34+
Response query();
3335
Response startup();
3436
Response bootStatus();
3537
Response info();
3638
Response stats();
3739
Response metrics();
3840
Response metricsJson();
41+
Response metricsHistory();
42+
Response metricsHistoryAlias();
3943
Response connections();
4044
Response rocksdb();
4145
Response rocksdbInternal();
4246
Response docTotal();
4347
Response etc();
48+
Response searchConfig();
49+
Response cache();
50+
Response updateCounters(const std::map<std::string, std::string>& params = {});
51+
Response updateCountersPost(const nlohmann::json& body = nlohmann::json::object());
52+
Response debugCounters();
53+
Response repair(const std::map<std::string, std::string>& params = {});
54+
Response repairPost(const nlohmann::json& body = nlohmann::json::object());
4455
Response sql(const std::string& sql, const std::map<std::string, std::string>& params = {});
4556
Response execSql(const std::string& sql);
4657
Response ping();

0 commit comments

Comments
 (0)