44
55<div align =" center " >
66
7- ** A C++ API for a high-performance search engine built for modern applications**
7+ ** A C++ API for a high-performance search engine built for modern applications. **
88
9- [ ![ Twitter Follow] ( https://img.shields.io/twitter/url/https/x.com/hlquery.svg?style=social&label=Follow%20%40hlquery )] ( https://x.com/hlquery )
9+ [ ![ Follow hlquery ] ( https://img.shields.io/badge/Follow-%40hlquery-blue?logo=x&logoColor=white )] ( https://x.com/hlquery )
1010[ ![ Linux Build] ( https://github.com/hlquery/cpp-api/workflows/Linux%20build/badge.svg )] ( https://github.com/hlquery/cpp-api/actions )
1111[ ![ macOS Build] ( https://github.com/hlquery/cpp-api/workflows/macOS%20Build/badge.svg )] ( https://github.com/hlquery/cpp-api/actions )
1212[ ![ Commit Activity] ( https://img.shields.io/github/commit-activity/m/hlquery/cpp-api )] ( https://github.com/hlquery/cpp-api/pulse )
1313[ ![ GitHub stars] ( https://img.shields.io/github/stars/hlquery/cpp-api?style=social )] ( https://github.com/hlquery/cpp-api/stargazers )
1414[ ![ License] ( https://img.shields.io/badge/License-BSD%203--Clause-blue.svg )] ( https://opensource.org/licenses/BSD-3-Clause )
1515
16- [ Documentation] ( https://docs.hlquery.com ) • [ GitHub] ( https://github.com/hlquery/cpp-api ) • [ Discord] ( https://discord.hlquery.com )
17-
1816</div >
1917
2018
2119### hlquery C++ API Client
2220
2321A C++ client library for hlquery with modular APIs, authentication support, HTTPS support, and type-safe responses.
2422
25- ## Features
23+ ### Features
2624
2725- ** Modular Architecture** : Clean separation of concerns with organized classes
2826- ** Intuitive API** : Familiar and easy-to-use structure
@@ -32,13 +30,13 @@ A C++ client library for hlquery with modular APIs, authentication support, HTTP
3230- ** Comprehensive Validation** : Input validation for all operations
3331- ** Minimal Dependencies** : Uses nlohmann/json (included) and standard C++ libraries
3432
35- ## Requirements
33+ ### Requirements
3634
3735- C++17 or later
3836- nlohmann/json (included in ` vendor/json/json.hpp ` )
3937- OpenSSL (optional, for HTTPS support)
4038
41- ## Installation
39+ ### Installation
4240
4341Build the client and examples locally:
4442
@@ -67,8 +65,6 @@ $ make OPENSSL=0
6765$ make OPENSSL=1
6866```
6967
70- ## Building
71-
7268### Using Make
7369
7470``` bash
@@ -106,7 +102,7 @@ On systems where OpenSSL is installed outside the default compiler include path
106102(for example Homebrew on macOS), the Makefile now pulls both compiler and linker
107103flags from ` pkg-config ` .
108104
109- ## Quick Start
105+ ### Quick Start
110106
111107``` cpp
112108#include " hlquery/client.h"
@@ -137,34 +133,6 @@ int main() {
137133}
138134```
139135
140- ## Reduce Text Example
141-
142- If the ` ai_search ` module is enabled, you can use ` executeRequest() ` to summarize a stored document:
143-
144- ``` cpp
145- #include " hlquery/client.h"
146- #include < iostream>
147- #include < map>
148-
149- int main () {
150- hlquery::Client client("http://localhost:9200");
151-
152- auto summary = client.executeRequest(
153- "GET",
154- "/modules/ai_search/talk",
155- nullptr,
156- {
157- {"q", "summarize onboarding guide in docs"},
158- {"run", "true"},
159- }
160- );
161-
162- std::cout << summary.getRawBody() << std::endl;
163- return 0;
164- }
165- ```
166-
167-
168136### Authentication
169137
170138``` cpp
@@ -178,42 +146,6 @@ client.setAuthToken("your_api_key", "api-key");
178146client.clearAuth();
179147```
180148
181- ### Collections API
182-
183- ``` cpp
184- // List collections
185- auto collections = client.listCollections(0 , 10 );
186-
187- // Get collection
188- auto collection = client.getCollection(" my_collection" );
189-
190- // Get collection fields
191- auto fields = client.getCollectionFields(" my_collection" );
192-
193- // Using Collections object directly
194- auto collections_api = client.collections();
195- auto result = collections_api->create ("new_collection", schema);
196- ```
197-
198- ### Documents API
199-
200- ```cpp
201- // List documents
202- std::map<std::string, std::string> params;
203- params["offset"] = "0";
204- params["limit"] = "10";
205- auto documents = client.listDocuments("collection", params);
206-
207- // Get document
208- auto document = client.getDocument("collection", "doc_id");
209-
210- // Add document
211- nlohmann::json doc;
212- doc["id"] = "doc_1";
213- doc["title"] = "Test";
214- auto result = client.documents()->add("collection", doc);
215- ```
216-
217149### Search API
218150
219151``` cpp
@@ -270,38 +202,3 @@ nlohmann::json vector_body = {
270202auto advanced = client.executeRequest(" POST" , " /collections/collection/vector_search" , vector_body);
271203```
272204
273- ### Ranking helpers
274-
275- ` hlquery::Ranker ` exposes helpers to recompute ` rank_signal ` and attach a ` sort_by ` clause so you can boost by popularity/hit metrics.
276-
277- ``` cpp
278- std::map<std::string, std::string> params;
279- params[" q" ] = " guide" ;
280- double signal = Ranker::ComputeRankSignal(popularity, hit_log);
281- params[" rank_signal" ] = std::to_string(signal);
282- Ranker::AttachRankSort (params);
283- auto results = client.search("collection", params);
284- ```
285-
286- ## Response Handling
287-
288- All methods return a `Response` object:
289-
290- ```cpp
291- auto response = client.health();
292-
293- // Check status
294- if (response.isSuccess()) {
295- auto body = response.getBody();
296- // Process body...
297- }
298-
299- // Get error
300- if (response.isError()) {
301- std::string error = response.getError();
302- std::cerr << "Error: " << error << std::endl;
303- }
304-
305- // Access JSON body
306- nlohmann::json body = response.getBody();
307- ```
0 commit comments