Skip to content

Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences

#14: Debug end-point that displays the Typesense version.

Kishore Nallan40cf5413c3fe
diff --git a/include/api.h b/include/api.h
index e93a3b98..3b711c59 100644
--- a/include/api.h
+++ b/include/api.h
@@ -10,6 +10,8 @@ void post_create_collection(http_req & req, http_res & res);
void del_drop_collection(http_req & req, http_res & res);
+void get_debug(http_req & req, http_res & res);
+
void get_search(http_req & req, http_res & res);
void get_collection_summary(http_req & req, http_res & res);
diff --git a/src/api.cpp b/src/api.cpp
index 9a286a9d..002fe140 100644
--- a/src/api.cpp
+++ b/src/api.cpp
@@ -3,6 +3,7 @@
#include <thread>
#include <sys/resource.h>
#include "api.h"
+#include "typesense_version.h"
#include "string_utils.h"
#include "collection.h"
#include "collection_manager.h"
@@ -143,6 +144,12 @@ void del_drop_collection(http_req & req, http_res & res) {
res.send_200(collection_json.dump());
}
+void get_debug(http_req & req, http_res & res) {
+ nlohmann::json result;
+ result["version"] = TYPESENSE_VERSION;
+ res.send_200(result.dump());
+}
+
void get_search(http_req & req, http_res & res) {
auto begin = std::chrono::high_resolution_clock::now();
diff --git a/src/main/typesense_server.cpp b/src/main/typesense_server.cpp
index 35c39a39..31ebbea6 100644
--- a/src/main/typesense_server.cpp
+++ b/src/main/typesense_server.cpp
@@ -39,6 +39,9 @@ void master_server_routes() {
server->get("/collections/:collection/documents/:id", get_fetch_document);
server->del("/collections/:collection/documents/:id", del_remove_document);
+ // meta
+ server->get("/debug", get_debug);
+
// replication
server->get("/replication/updates", get_replication_updates, true);
}
@@ -53,6 +56,9 @@ void replica_server_routes() {
server->get("/collections/:collection/documents/export", get_collection_export, true);
server->get("/collections/:collection/documents/:id", get_fetch_document);
+ // meta
+ server->get("/debug", get_debug);
+
// replication
server->get("/replication/updates", get_replication_updates, true);
}