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
C++ algoliadatastoreelasticsearchenterprise-searchfacetingfull-text-searchfuzzy-searchgeosearchin-memoryinstantsearchmerchandisingpineconesearchsearch-enginesemantic-searchsimilarity-searchsite-searchsynonymstypo-tolerancevector-search
Fix float stats with negative only value.
Kishore Nallan67b6b00b379a
diff --git a/include/field.h b/include/field.hindex 0f959b7d..6d262eba 100644--- a/include/field.h+++ b/include/field.h@@ -754,7 +754,7 @@ struct facet_count_t {struct facet_stats_t {double fvmin = std::numeric_limits<double>::max(),- fvmax = -std::numeric_limits<double>::min(),+ fvmax = -std::numeric_limits<double>::max(),fvcount = 0,fvsum = 0;};diff --git a/test/collection_faceting_test.cpp b/test/collection_faceting_test.cppindex 5e9c1e9d..73f22508 100644--- a/test/collection_faceting_test.cpp+++ b/test/collection_faceting_test.cpp@@ -711,6 +711,30 @@ TEST_F(CollectionFacetingTest, FacetStatOnFloatFields) {collectionManager.drop_collection("coll_float_fields");}+TEST_F(CollectionFacetingTest, FacetStatsFloatLon) {+ std::vector<field> fields = {+ field("lon", field_types::FLOAT, true),+ };++ Collection* coll1 = collectionManager.create_collection("coll1", 1, fields).get();++ nlohmann::json doc;+ doc["lon"] = -99.184319;+ ASSERT_TRUE(coll1->add(doc.dump()).ok());++ auto results = coll1->search("*", {},+ "", {"lon"}, {}, {2}, 10, 1, FREQUENCY, {true}, 1).get();++ ASSERT_EQ(1, results["facet_counts"].size());+ ASSERT_EQ(5, results["facet_counts"][0]["stats"].size());++ ASSERT_FLOAT_EQ(-99.1843, results["facet_counts"][0]["stats"]["avg"].get<double>());+ ASSERT_FLOAT_EQ(-99.1843, results["facet_counts"][0]["stats"]["min"].get<double>());+ ASSERT_FLOAT_EQ(-99.1843, results["facet_counts"][0]["stats"]["max"].get<double>());+ ASSERT_FLOAT_EQ(-99.1843, results["facet_counts"][0]["stats"]["sum"].get<double>());+ ASSERT_FLOAT_EQ(1, results["facet_counts"][0]["stats"]["total_values"].get<size_t>());+}+TEST_F(CollectionFacetingTest, FacetCountOnSimilarStrings) {Collection *coll1;