You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The hlquery C++ API is the official C++ client for hlquery. It wraps the server's HTTP/JSON interface in a small typed client with response helpers, auth support, SQL helpers, and SAM support.
20
21
21
-
A C++ client library for hlquery with modular APIs, authentication support, HTTPS support, type-safe responses, and basic SAM search helpers.
22
+
It is intended for native services, command-line tools, and applications that want direct hlquery access without hand-rolling HTTP calls.
22
23
23
-
### Installation
24
+
### Why use it?
24
25
25
-
Build the client and examples locally:
26
+
- Less request and parsing boilerplate than raw HTTP.
27
+
- One client entry point for collections, documents, search, SQL, and SAM.
28
+
- Optional HTTPS/OpenSSL support.
29
+
- Works well for native applications that want a small static client library.
26
30
27
-
```bash
28
-
$ cd cpp-api
29
-
$ make
30
-
```
31
-
32
-
On FreeBSD, use GNU make:
33
-
34
-
```bash
35
-
$ cd cpp-api
36
-
$ gmake
37
-
```
38
-
39
-
Build modes:
40
-
41
-
```bash
42
-
# Auto-detect OpenSSL with pkg-config (default)
43
-
$ make
31
+
### Why choose it over raw HTTP?
44
32
45
-
# Force HTTP-only build with no OpenSSL dependency
46
-
$ make OPENSSL=0
33
+
- Consistent request setup and auth handling.
34
+
- Convenience wrappers for common hlquery endpoints.
35
+
- Type-safe response objects with predictable access patterns.
36
+
- Raw request escape hatch still exists for custom routes.
47
37
48
-
# Require OpenSSL and fail fast if it is not available
49
-
$ make OPENSSL=1
50
-
```
51
-
52
-
### Using Make
53
-
54
-
```bash
55
-
$ cd cpp-api
56
-
$ make
57
-
```
38
+
### Install
58
39
59
-
FreeBSD:
40
+
Build locally:
60
41
61
42
```bash
62
-
$ cd cpp-api
63
-
$ gmake
43
+
make
64
44
```
65
45
66
-
This will build:
67
-
-`build/libhlqueryclient.a` - Static library
68
-
-`build/basic_usage` - Example executable
46
+
On FreeBSD, use:
69
47
70
-
All build artifacts are placed in the `build/` directory.
71
-
72
-
To clean build artifacts:
73
48
```bash
74
-
$ make clean
49
+
gmake
75
50
```
76
51
77
-
On FreeBSD:
52
+
Build modes:
78
53
79
54
```bash
80
-
$ gmake clean
55
+
make OPENSSL=0
56
+
make OPENSSL=1
81
57
```
82
58
83
-
This removes the entire `build/` directory.
84
-
85
-
On systems where OpenSSL is installed outside the default compiler include path
86
-
(for example Homebrew on macOS), the Makefile now pulls both compiler and linker
auto advanced = client.executeRequest("POST", "/collections/collection/vector_search", vector_body);
224
-
225
-
// SAM search
226
-
auto sam = client.samSearch("collection", "wireless keyboard");
227
-
auto sam_all = client.samSearchAll("guide", {{"limit", "5"}});
228
-
```
229
-
230
-
Preferred structure:
103
+
SAM is separate from vector search. It performs term and intent-style lookup, not vector similarity search.
231
104
232
105
```cpp
233
-
auto collections = client.collections();
234
-
auto result = collections->search("products", {{"like", "laptop"}});
235
-
```
236
-
237
-
Compatibility note:
238
-
239
-
-`client.searchApi()`
240
-
-`client.search(...)`
241
-
-`client.sqlSearch(...)`
242
-
-`client.vectorSearch(...)`
243
-
244
-
still exist for now, but they are compatibility shims. New code should prefer `client.collections()->search(...)`, `client.sql(...)`, and `client.collections()->vectorSearch(...)`.
245
-
246
-
### SAM Search
247
-
248
-
SAM search calls `/sam/search` directly and is useful for broader intent-style lookup.
249
-
250
-
```cpp
251
-
auto sam = client.samSearch("products", "nineteen");
252
-
auto sam_all = client.samSearchAll("benchmark", {{"distributed", "on"}, {"limit", "10"}});
253
-
```
254
-
255
-
### Collections And Documents
256
-
257
-
```cpp
258
-
auto collections = client.collections();
259
-
auto documents = client.documents();
260
-
261
-
nlohmann::json schema = {
262
-
{"fields", nlohmann::json::array({
263
-
{{"name", "title"}, {"type", "string"}},
264
-
{{"name", "content"}, {"type", "string"}},
265
-
{{"name", "price"}, {"type", "float"}}
266
-
})}
267
-
};
268
-
269
-
auto created = collections->create("products", schema);
270
-
auto updated = collections->update("products", {
271
-
{"add_fields", nlohmann::json::array({
272
-
{{"name", "brand"}, {"type", "string"}}
273
-
})}
274
-
});
275
-
276
-
auto added = documents->add("products", {
277
-
{"id", "sku-1"},
278
-
{"title", "Laptop Computer"},
279
-
{"content", "High-performance laptop with 16GB RAM"},
280
-
{"price", 1299.0}
281
-
});
106
+
hlquery::Client client("http://localhost:9200");
282
107
283
-
auto changed = documents->update("products", "sku-1", {
284
-
{"price", 1199.0},
285
-
{"brand", "hlquery"}
108
+
auto sam = client.sam();
109
+
auto status = sam->status("music");
110
+
auto history = sam->history("music", 5);
111
+
auto results = sam->search("music", "queen of pop", {
112
+
{"limit", "10"}
286
113
});
287
114
288
-
auto removed = documents->remove("products", "sku-1");
0 commit comments