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

changing base to v0.26-filter

krunal1313e1050d0102ff
diff --git a/include/field.h b/include/field.h
index 3876c326..695c5114 100644
--- a/include/field.h
+++ b/include/field.h
@@ -651,9 +651,11 @@ struct facet {
bool sampled = false;
+ bool is_wildcard_match = false;
+
bool is_intersected = false;
- bool get_range(std::string key, std::pair<int64_t, std::string>& range_pair)
+ bool get_range(std::string key, std::pair<std::string, std::string>& range_pair)
{
if(facet_range_map.empty())
{
diff --git a/include/index.h b/include/index.h
index 89a27be3..559493b0 100644
--- a/include/index.h
+++ b/include/index.h
@@ -510,8 +510,6 @@ private:
static void compute_facet_stats(facet &a_facet, const int64_t raw_value, const std::string & field_type);
- static void compute_facet_stats(facet &a_facet, const int64_t raw_value, const std::string & field_type);
-
static void handle_doc_ops(const tsl::htrie_map<char, field>& search_schema,
nlohmann::json& update_doc, const nlohmann::json& old_doc, nlohmann::json& new_doc);
@@ -946,6 +944,8 @@ public:
std::map<size_t, std::map<size_t, uint32_t>>& included_ids_map,
std::vector<uint32_t>& included_ids_vec,
std::unordered_set<uint32_t>& excluded_group_ids) const;
+
+ int64_t get_doc_val_from_sort_index(sort_index_iterator it, uint32_t doc_seq_id) const;
friend class filter_result_iterator_t;
};
diff --git a/src/collection.cpp b/src/collection.cpp
index d1c234b2..3ca03923 100644
--- a/src/collection.cpp
+++ b/src/collection.cpp
@@ -4651,17 +4651,23 @@ Option<bool> Collection::parse_facet(const std::string& facet_field, std::vector
auto pos2 = range.find(",");
auto pos3 = range.find("]");
- int64_t lower_range, upper_range;
+ std::string lower_range, upper_range;
+ auto lower_range_start = pos1 + 2;
+ auto lower_range_len = pos2 - lower_range_start;
+ auto upper_range_start = pos2 + 1;
+ auto upper_range_len = pos3 - upper_range_start;
if(a_field.is_integer()) {
- lower_range = std::stoll(range.substr(pos1 + 2, pos2));
- upper_range = std::stoll(range.substr(pos2 + 1, pos3));
+ lower_range = range.substr(lower_range_start, lower_range_len);
+ StringUtils::trim(lower_range);
+ upper_range = range.substr(upper_range_start, upper_range_len);
+ StringUtils::trim(upper_range);
} else {
float val = std::stof(range.substr(pos1 + 2, pos2));
- lower_range = Index::float_to_int64_t(val);
+ lower_range = std::to_string(Index::float_to_int64_t(val));
val = std::stof(range.substr(pos2 + 1, pos3));
- upper_range = Index::float_to_int64_t(val);
+ upper_range = std::to_string(Index::float_to_int64_t(val));
}
tupVec.emplace_back(std::make_tuple(lower_range, upper_range, range_val));
diff --git a/src/index.cpp b/src/index.cpp
index f9840c98..e5e3d3a3 100644
--- a/src/index.cpp
+++ b/src/index.cpp
@@ -2472,7 +2472,8 @@ Option<bool> Index::search(std::vector<query_tokens_t>& field_query_tokens, cons
auto is_wildcard_query = !field_query_tokens.empty() && !field_query_tokens[0].q_include_tokens.empty() &&
field_query_tokens[0].q_include_tokens[0].value == "*";
- bool no_filters_provided = (filter_tree_root == nullptr && filter_result.count == 0);
+
+ bool no_filters_provided = (filter_tree_root == nullptr && !filter_result_iterator->is_valid);
// handle phrase searches
@@ -5328,7 +5329,6 @@ void Index::score_results(const std::vector<sort_by> & sort_fields, const uint16
if(group_limit != 0) {
distinct_id = get_distinct_id(group_by_fields, seq_id);
- groups_processed.emplace(distinct_id);
}
//LOG(INFO) << "Seq id: " << seq_id << ", match_score: " << match_score;
diff --git a/test/collection_optimized_faceting_test.cpp b/test/collection_optimized_faceting_test.cpp
index 7244d54e..972e1169 100644
--- a/test/collection_optimized_faceting_test.cpp
+++ b/test/collection_optimized_faceting_test.cpp
@@ -860,7 +860,7 @@ TEST_F(CollectionOptimizedFacetingTest, RangeFacetTest) {
"", true, 0UL, max_score, 100UL, 0UL, 4294967295UL, true);
ASSERT_FALSE(rop.ok());
- ASSERT_EQ("Range facet is restricted to only int32 and int64 fields.", rop.error());
+ ASSERT_EQ("Range facet is restricted to only integer and float fields.", rop.error());
// ensure that bad facet range values are handled
rop = coll1->search("Karnataka", {"state"},