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

add alphanumeric range facet labels & minor bug fix

krunal058b8be621e9
diff --git a/src/collection.cpp b/src/collection.cpp
index c53677d7..abef4b13 100644
--- a/src/collection.cpp
+++ b/src/collection.cpp
@@ -5850,7 +5850,7 @@ bool Collection::get_enable_nested_fields() {
Option<bool> Collection::parse_facet(const std::string& facet_field, std::vector<facet>& facets) const {
const std::regex base_pattern(".+\\(.*\\)");
- const std::regex range_pattern("[[a-z A-Z]+:\\[([+-]?([0-9]*[.])?[0-9]*)\\,\\s*([+-]?([0-9]*[.])?[0-9]*)\\]");
+ const std::regex range_pattern("[[0-9]*[a-z A-Z]+[0-9]*:\\[([+-]?([0-9]*[.])?[0-9]*)\\,\\s*([+-]?([0-9]*[.])?[0-9]*)\\]");
const std::string _alpha = "_alpha";
if ((facet_field.find(":") != std::string::npos)
diff --git a/src/index.cpp b/src/index.cpp
index a4d83f63..0287f443 100644
--- a/src/index.cpp
+++ b/src/index.cpp
@@ -1389,7 +1389,7 @@ void Index::do_facets(std::vector<facet> & facets, facet_query_t & facet_query,
if(a_facet.get_range(std::stoll(doc_val), range_pair)) {
const auto& range_id = range_pair.first;
facet_count_t& facet_count = a_facet.result_map[range_id];
- facet_count.count = kv.second.count;
+ facet_count.count += kv.second.count;
}
} else {
facet_count_t& facet_count = a_facet.value_result_map[kv.first];