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

Rename collection.h and collection.cpp to index.h and index.cpp.

Kishore Nallan883a9f14a0f2
diff --git a/include/collection.h b/include/index.h
similarity index 99%
rename from include/collection.h
rename to include/index.h
index b19b846d..21954c0b 100644
--- a/include/collection.h
+++ b/include/index.h
@@ -176,7 +176,6 @@ public:
Option<uint32_t> index_in_memory(const nlohmann::json & document, uint32_t seq_id);
- //enum {MAX_SEARCH_TOKENS = 10};
static const int MAX_SEARCH_TOKENS = 10;
static const int MAX_RESULTS = 100;
diff --git a/src/collection.cpp b/src/index.cpp
similarity index 99%
rename from src/collection.cpp
rename to src/index.cpp
index d15d919f..2c548e5b 100644
--- a/src/collection.cpp
+++ b/src/index.cpp
@@ -1,4 +1,4 @@
-#include "collection.h"
+#include "index.h"
#include <numeric>
#include <chrono>
@@ -801,15 +801,6 @@ Option<nlohmann::json> Collection::search(std::string query, const std::vector<s
sort_fields_std.push_back({_sort_field.name, sort_order});
}
- // process the filters
- uint32_t* filter_ids = nullptr;
- Option<uint32_t> op_filter_ids_length = do_filtering(&filter_ids, simple_filter_query);
- if(!op_filter_ids_length.ok()) {
- return Option<nlohmann::json>(op_filter_ids_length.code(), op_filter_ids_length.error());
- }
-
- const uint32_t filter_ids_length = op_filter_ids_length.get();
-
// check for valid pagination
if(page < 1) {
std::string message = "Page must be an integer of value greater than 0.";
@@ -823,6 +814,15 @@ Option<nlohmann::json> Collection::search(std::string query, const std::vector<s
const size_t num_results = (page * per_page);
+ // process the filters
+ uint32_t* filter_ids = nullptr;
+ Option<uint32_t> op_filter_ids_length = do_filtering(&filter_ids, simple_filter_query);
+ if(!op_filter_ids_length.ok()) {
+ return Option<nlohmann::json>(op_filter_ids_length.code(), op_filter_ids_length.error());
+ }
+
+ const uint32_t filter_ids_length = op_filter_ids_length.get();
+
// Order of `fields` are used to sort results
auto begin = std::chrono::high_resolution_clock::now();
std::vector<std::pair<int, Topster<100>::KV>> field_order_kvs;