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
Allow num_typos to be configured at a per-field level.
Kishore Nallan78ea80153ffd
diff --git a/include/collection.h b/include/collection.hindex d56bf68e..effe0374 100644--- a/include/collection.h+++ b/include/collection.h@@ -511,7 +511,7 @@ public:Option<nlohmann::json> search(const std::string & query, const std::vector<std::string> & search_fields,const std::string & simple_filter_query, const std::vector<std::string> & facet_fields,- const std::vector<sort_by> & sort_fields, int num_typos,+ const std::vector<sort_by> & sort_fields, const std::vector<uint32_t>& num_typos,size_t per_page = 10, size_t page = 1,token_ordering token_order = FREQUENCY, bool prefix = false,size_t drop_tokens_threshold = Index::DROP_TOKENS_THRESHOLD,diff --git a/include/index.h b/include/index.hindex 25b69a6a..e338f181 100644--- a/include/index.h+++ b/include/index.h@@ -52,7 +52,7 @@ struct search_args {std::vector<uint32_t> excluded_ids;std::vector<sort_by> sort_fields_std;facet_query_t facet_query;- int num_typos;+ std::vector<uint32_t> num_typos;size_t max_facet_values;size_t per_page;size_t page;@@ -79,8 +79,8 @@ struct search_args {search_args(std::vector<query_tokens_t> field_query_tokens,std::vector<search_field_t> search_fields, std::vector<filter> filters,std::vector<facet> facets, std::map<size_t, std::map<size_t, uint32_t>> included_ids, std::vector<uint32_t> excluded_ids,- std::vector<sort_by> sort_fields_std, facet_query_t facet_query, int num_typos, size_t max_facet_values,- size_t max_hits, size_t per_page, size_t page, token_ordering token_order, bool prefix,+ std::vector<sort_by> sort_fields_std, facet_query_t facet_query, const std::vector<uint32_t>& num_typos,+ size_t max_facet_values, size_t max_hits, size_t per_page, size_t page, token_ordering token_order, bool prefix,size_t drop_tokens_threshold, size_t typo_tokens_threshold,const std::vector<std::string>& group_by_fields, size_t group_limit,const std::string& default_sorting_field,@@ -345,7 +345,7 @@ public:facet_query_t & facet_query,const std::map<size_t, std::map<size_t, uint32_t>> & included_ids_map,const std::vector<uint32_t> & excluded_ids,- const std::vector<sort_by> & sort_fields_std, const int num_typos,+ const std::vector<sort_by> & sort_fields_std, const std::vector<uint32_t>& num_typos,Topster* topster, Topster* curated_topster,const size_t per_page, const size_t page, const token_ordering token_order,const bool prefix, const size_t drop_tokens_threshold,diff --git a/src/collection.cpp b/src/collection.cppindex 4cf6656f..f72e17d7 100644--- a/src/collection.cpp+++ b/src/collection.cpp@@ -484,7 +484,7 @@ void Collection::populate_overrides(std::string query,Option<nlohmann::json> Collection::search(const std::string & query, const std::vector<std::string>& search_fields,const std::string & simple_filter_query, const std::vector<std::string>& facet_fields,- const std::vector<sort_by> & sort_fields, const int num_typos,+ const std::vector<sort_by> & sort_fields, const std::vector<uint32_t>& num_typos,const size_t per_page, const size_t page,token_ordering token_order, const bool prefix,const size_t drop_tokens_threshold,@@ -522,6 +522,13 @@ Option<nlohmann::json> Collection::search(const std::string & query, const std::std::to_string(GROUP_LIMIT_MAX) + ".");}+ if(!search_fields.empty() && search_fields.size() != num_typos.size()) {+ if(num_typos.size() != 1) {+ return Option<nlohmann::json>(400, "Number of weights in `num_typos` does not match "+ "number of `query_by` fields.");+ }+ }+std::vector<uint32_t> excluded_ids;std::map<size_t, std::vector<uint32_t>> include_ids; // position => list of IDsstd::map<size_t, std::vector<std::string>> pinned_hits;diff --git a/src/collection_manager.cpp b/src/collection_manager.cppindex 81c88e2c..85722d47 100644--- a/src/collection_manager.cpp+++ b/src/collection_manager.cpp@@ -612,8 +612,22 @@ Option<bool> CollectionManager::do_search(std::map<std::string, std::string>& rereturn Option<bool>(400, "Parameter `" + std::string(TYPO_TOKENS_THRESHOLD) + "` must be an unsigned integer.");}- if(!StringUtils::is_uint32_t(req_params[NUM_TYPOS])) {- return Option<bool>(400,"Parameter `" + std::string(NUM_TYPOS) + "` must be an unsigned integer.");+ std::vector<uint32_t> num_typos;++ if(req_params[NUM_TYPOS].size() == 1 && StringUtils::is_uint32_t(req_params[NUM_TYPOS])) {+ num_typos = {(uint32_t)std::stoi(req_params[NUM_TYPOS])};+ } else {+ std::vector<std::string> num_typos_str;+ StringUtils::split(req_params[NUM_TYPOS], num_typos_str, ",");+ for(auto& typo_s : num_typos_str) {+ if(StringUtils::is_uint32_t(typo_s)) {+ num_typos.push_back((uint32_t)std::stoi(typo_s));+ }+ }++ if(num_typos.size() == 0) {+ return Option<bool>(400, "Parameter `" + std::string(NUM_TYPOS) + "` is malformed.");+ }}if(!StringUtils::is_uint32_t(req_params[PER_PAGE])) {@@ -708,7 +722,7 @@ Option<bool> CollectionManager::do_search(std::map<std::string, std::string>& re}Option<nlohmann::json> result_op = collection->search(req_params[QUERY], search_fields, filter_str, facet_fields,- sort_fields, std::stoi(req_params[NUM_TYPOS]),+ sort_fields, num_typos,static_cast<size_t>(std::stol(req_params[PER_PAGE])),static_cast<size_t>(std::stol(req_params[PAGE])),token_order, prefix, drop_tokens_threshold,diff --git a/src/index.cpp b/src/index.cppindex 2b80f9e9..aa4908ab 100644--- a/src/index.cpp+++ b/src/index.cpp@@ -1483,7 +1483,7 @@ void Index::search(const std::vector<query_tokens_t>& field_query_tokens,std::vector<facet>& facets, facet_query_t& facet_query,const std::map<size_t, std::map<size_t, uint32_t>> & included_ids_map,const std::vector<uint32_t> & excluded_ids,- const std::vector<sort_by> & sort_fields_std, const int num_typos,+ const std::vector<sort_by> & sort_fields_std, const std::vector<uint32_t>& num_typos,Topster* topster,Topster* curated_topster,const size_t per_page, const size_t page, const token_ordering token_order,@@ -1628,6 +1628,9 @@ void Index::search(const std::vector<query_tokens_t>& field_query_tokens,q_pos_synonyms.emplace_back(q_pos_syn);}+ // num_typos is already validated upstream, but still playing safe+ int field_num_typos = (i < num_typos.size()) ? num_typos[i] : num_typos[0];+// proceed to query search only when no filters are provided or when filtering produces resultsif(filters.empty() || filter_ids_length > 0) {const uint8_t field_id = (uint8_t)(FIELD_LIMIT_NUM - i);@@ -1649,7 +1652,7 @@ void Index::search(const std::vector<query_tokens_t>& field_query_tokens,search_field(field_id, query_tokens, search_tokens, exclude_token_ids, exclude_token_ids_size, num_tokens_dropped,field_name, filter_ids, filter_ids_length, curated_ids_sorted, facets, sort_fields_std,- num_typos, searched_queries, actual_topster, groups_processed, &all_result_ids, all_result_ids_len,+ field_num_typos, searched_queries, actual_topster, groups_processed, &all_result_ids, all_result_ids_len,field_num_results, group_limit, group_by_fields, prioritize_exact_match, token_order, prefix,drop_tokens_threshold, typo_tokens_threshold);@@ -1661,7 +1664,7 @@ void Index::search(const std::vector<query_tokens_t>& field_query_tokens,search_field(field_id, query_tokens, search_tokens, exclude_token_ids, exclude_token_ids_size, num_tokens_dropped,field_name, filter_ids, filter_ids_length, curated_ids_sorted, facets, sort_fields_std,- num_typos, searched_queries, actual_topster, groups_processed, &all_result_ids, all_result_ids_len,+ field_num_typos, searched_queries, actual_topster, groups_processed, &all_result_ids, all_result_ids_len,field_num_results, group_limit, group_by_fields, prioritize_exact_match, token_order, prefix,drop_tokens_threshold, typo_tokens_threshold);}@@ -1687,8 +1690,11 @@ void Index::search(const std::vector<query_tokens_t>& field_query_tokens,}uint32_t token_bits = (uint32_t(1) << 31); // top most bit set to guarantee atleast 1 bit set- uint64_t total_typos = 0, total_distances = 0, exact_matches = 0;- uint64_t num_query_matches = 0;+ uint64_t total_typos = 0, total_distances = 0;++ uint64_t verbatim_matches = 0; // query matching field verbatim+ uint64_t query_matches = 0; // field containing query tokens+ uint64_t cross_field_matches = 0; // total matches across fields (including fuzzy ones)//LOG(INFO) << "Init pop count: " << __builtin_popcount(token_bits);@@ -1709,12 +1715,14 @@ void Index::search(const std::vector<query_tokens_t>& field_query_tokens,int64_t field_typos = 255 - ((match_score >> 16) & 0xFF);total_typos += (field_typos + 1) * weight;total_distances += ((100 - ((match_score >> 8) & 0xFF)) + 1) * weight;- exact_matches += (((match_score & 0xFF)) + 1) * weight;+ verbatim_matches += (((match_score & 0xFF)) + 1) * weight;if(field_typos == 0 && tokens_found == field_query_tokens[i].q_include_tokens.size()) {- num_query_matches++;+ query_matches++;}+ cross_field_matches += tokens_found;+/*LOG(INFO) << "seq_id: " << seq_id << ", total_typos: " << (255 - ((match_score >> 8) & 0xFF))<< ", weighted typos: " << std::max<uint64_t>((255 - ((match_score >> 8) & 0xFF)), 1) * weight<< ", total dist: " << (((match_score & 0xFF)))@@ -1765,9 +1773,11 @@ void Index::search(const std::vector<query_tokens_t>& field_query_tokens,total_typos += (field_typos + 1) * weight;if(field_typos == 0 && tokens_found == field_query_tokens[i].q_include_tokens.size()) {- num_query_matches++;- exact_matches++;+ query_matches++;+ verbatim_matches++;}++ cross_field_matches += tokens_found;//LOG(INFO) << "seq_id: " << seq_id << ", total_typos: " << ((match_score >> 8) & 0xFF);}}@@ -1777,11 +1787,12 @@ void Index::search(const std::vector<query_tokens_t>& field_query_tokens,total_distances = std::min<uint64_t>(100, total_distances);uint64_t aggregated_score = (- (num_query_matches << 32) |- (tokens_present << 24) |+ (query_matches << 40) |+ (tokens_present << 32) |+ (cross_field_matches << 24) |((255 - total_typos) << 16) |((100 - total_distances) << 8) |- (exact_matches)+ (verbatim_matches));/*LOG(INFO) << "seq id: " << seq_id << ", tokens_present: " << tokens_presentdiff --git a/test/collection_all_fields_test.cpp b/test/collection_all_fields_test.cppindex ccac0b09..d8589516 100644--- a/test/collection_all_fields_test.cpp+++ b/test/collection_all_fields_test.cpp@@ -83,7 +83,7 @@ TEST_F(CollectionAllFieldsTest, IndexDocsWithoutSchema) {ASSERT_EQ(DIRTY_VALUES::DROP, coll1->parse_dirty_values_option(dirty_values));// same should succeed when verbatim filter is made- auto results = coll1->search("will", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ auto results = coll1->search("will", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(2, results["hits"].size());ASSERT_EQ(2, results["found"].get<size_t>());@@ -91,7 +91,7 @@ TEST_F(CollectionAllFieldsTest, IndexDocsWithoutSchema) {ASSERT_STREQ("1", results["hits"][0]["document"]["id"].get<std::string>().c_str());ASSERT_STREQ("0", results["hits"][1]["document"]["id"].get<std::string>().c_str());- results = coll1->search("chris", {"cast"}, "", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll1->search("chris", {"cast"}, "", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(3, results["hits"].size());ASSERT_EQ(3, results["found"].get<size_t>());@@ -118,7 +118,7 @@ TEST_F(CollectionAllFieldsTest, IndexDocsWithoutSchema) {add_op = coll1->add(doc_json);ASSERT_TRUE(add_op.ok());- results = coll1->search("300", {"title"}, "", {}, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll1->search("300", {"title"}, "", {}, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());ASSERT_STREQ("300", results["hits"][0]["document"]["title"].get<std::string>().c_str());@@ -130,7 +130,7 @@ TEST_F(CollectionAllFieldsTest, IndexDocsWithoutSchema) {add_op = coll1->add(doc_json, CREATE, "", DIRTY_VALUES::COERCE_OR_DROP);ASSERT_TRUE(add_op.ok());- results = coll1->search("With bad cast field", {"title"}, "", {}, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll1->search("With bad cast field", {"title"}, "", {}, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());ASSERT_STREQ("With bad cast field.", results["hits"][0]["document"]["title"].get<std::string>().c_str());ASSERT_EQ(0, results["hits"][0]["document"].count("cast"));@@ -143,10 +143,10 @@ TEST_F(CollectionAllFieldsTest, IndexDocsWithoutSchema) {add_op = coll1->add(doc_json, CREATE, "", DIRTY_VALUES::DROP);ASSERT_TRUE(add_op.ok());- results = coll1->search("1200", {"title"}, "", {}, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll1->search("1200", {"title"}, "", {}, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(0, results["hits"].size());- results = coll1->search("Jeremy Livingston", {"cast"}, "", {}, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll1->search("Jeremy Livingston", {"cast"}, "", {}, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());ASSERT_EQ(0, results["hits"][0]["document"].count("title"));@@ -160,7 +160,7 @@ TEST_F(CollectionAllFieldsTest, IndexDocsWithoutSchema) {// try querying using an non-existing sort fieldsort_fields = { sort_by("not-found", "DESC") };- auto res_op = coll1->search("*", {}, "", {}, sort_fields, 0, 10, 1, FREQUENCY, false);+ auto res_op = coll1->search("*", {}, "", {}, sort_fields, {0}, 10, 1, FREQUENCY, false);ASSERT_FALSE(res_op.ok());ASSERT_EQ("Could not find a field named `not-found` in the schema for sorting.", res_op.error());@@ -213,7 +213,7 @@ TEST_F(CollectionAllFieldsTest, HandleArrayTypes) {add_op = coll1->add(doc.dump(), CREATE, "", DIRTY_VALUES:: DROP);ASSERT_TRUE(add_op.ok());- auto results = coll1->search("second", {"title"}, "", {}, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ auto results = coll1->search("second", {"title"}, "", {}, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());// check that the "bad" value does not exists in the stored document@@ -234,7 +234,7 @@ TEST_F(CollectionAllFieldsTest, HandleArrayTypes) {add_op = coll1->add(doc.dump(), CREATE, "", DIRTY_VALUES::COERCE_OR_DROP);ASSERT_TRUE(add_op.ok());- results = coll1->search("third", {"title"}, "", {}, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll1->search("third", {"title"}, "", {}, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());ASSERT_EQ(0, results["hits"][0]["document"].count("int_values"));@@ -294,7 +294,7 @@ TEST_F(CollectionAllFieldsTest, ShouldBeAbleToUpdateSchemaDetectedDocs) {add_op = coll1->add(doc.dump(), UPDATE, "0", DIRTY_VALUES::COERCE_OR_DROP);ASSERT_TRUE(add_op.ok());- auto results = coll1->search("second", {"title"}, "", {}, {}, 0, 10, 1, FREQUENCY, false).get();+ auto results = coll1->search("second", {"title"}, "", {}, {}, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());ASSERT_EQ("SECOND", results["hits"][0]["document"]["title"].get<std::string>());@@ -341,7 +341,7 @@ TEST_F(CollectionAllFieldsTest, ShouldBeAbleToUpdateSchemaDetectedDocs) {res = coll1->add_many(json_lines, insert_doc, UPDATE);ASSERT_TRUE(res["success"].get<bool>());- results = coll1->search("updated", {"title"}, "", {}, {}, 0, 50, 1, FREQUENCY, false).get();+ results = coll1->search("updated", {"title"}, "", {}, {}, {0}, 50, 1, FREQUENCY, false).get();ASSERT_EQ(20, results["hits"].size());for(auto& hit: results["hits"]) {@@ -373,7 +373,7 @@ TEST_F(CollectionAllFieldsTest, StringifyAllValues) {ASSERT_EQ("1", added_doc["int_values"][0].get<std::string>());ASSERT_EQ("2", added_doc["int_values"][1].get<std::string>());- auto results = coll1->search("first", {"title"}, "", {}, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ auto results = coll1->search("first", {"title"}, "", {}, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());ASSERT_EQ("FIRST", results["hits"][0]["document"]["title"].get<std::string>());@@ -387,7 +387,7 @@ TEST_F(CollectionAllFieldsTest, StringifyAllValues) {add_op = coll1->add(doc.dump(), CREATE, "", DIRTY_VALUES::DROP);ASSERT_TRUE(add_op.ok());- results = coll1->search("second", {"title"}, "", {}, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll1->search("second", {"title"}, "", {}, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());ASSERT_EQ("SECOND", results["hits"][0]["document"]["title"].get<std::string>());ASSERT_EQ(1, results["hits"][0]["document"].count("int_values"));@@ -424,7 +424,7 @@ TEST_F(CollectionAllFieldsTest, StringifyAllValues) {add_op = coll1->add(doc.dump(), CREATE, "", DIRTY_VALUES::DROP);ASSERT_TRUE(add_op.ok());- results = coll1->search("fifth", {"title"}, "", {}, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll1->search("fifth", {"title"}, "", {}, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());ASSERT_EQ("FIFTH", results["hits"][0]["document"]["title"].get<std::string>());ASSERT_EQ(0, results["hits"][0]["document"].count("dict"));@@ -434,7 +434,7 @@ TEST_F(CollectionAllFieldsTest, StringifyAllValues) {add_op = coll1->add(doc.dump(), CREATE, "66", DIRTY_VALUES::COERCE_OR_DROP);ASSERT_TRUE(add_op.ok());- results = coll1->search("sixth", {"title"}, "", {}, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll1->search("sixth", {"title"}, "", {}, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());ASSERT_EQ("SIXTH", results["hits"][0]["document"]["title"].get<std::string>());ASSERT_EQ(0, results["hits"][0]["document"].count("dict"));@@ -464,11 +464,11 @@ TEST_F(CollectionAllFieldsTest, SearchStringifiedField) {Option<nlohmann::json> add_op = coll1->add(doc.dump(), CREATE, "0");ASSERT_TRUE(add_op.ok());- auto results_op = coll1->search("stark", {"company_name"}, "", {}, sort_fields, 0, 10, 1, FREQUENCY, false);+ auto results_op = coll1->search("stark", {"company_name"}, "", {}, sort_fields, {0}, 10, 1, FREQUENCY, false);ASSERT_TRUE(results_op.ok());ASSERT_EQ(1, results_op.get()["hits"].size());- results_op = coll1->search("engineering", {"department"}, "", {}, sort_fields, 0, 10, 1, FREQUENCY, false);+ results_op = coll1->search("engineering", {"department"}, "", {}, sort_fields, {0}, 10, 1, FREQUENCY, false);ASSERT_TRUE(results_op.ok());ASSERT_EQ(1, results_op.get()["hits"].size());@@ -501,7 +501,7 @@ TEST_F(CollectionAllFieldsTest, StringSingularAllValues) {ASSERT_EQ("FIRST", added_doc["title"].get<std::string>());ASSERT_EQ("123", added_doc["int_values"].get<std::string>());- auto results = coll1->search("first", {"title"}, "", {}, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ auto results = coll1->search("first", {"title"}, "", {}, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());ASSERT_EQ("FIRST", results["hits"][0]["document"]["title"].get<std::string>());ASSERT_EQ("123", results["hits"][0]["document"]["int_values"].get<std::string>());@@ -674,7 +674,7 @@ TEST_F(CollectionAllFieldsTest, WildcardFacetFieldsOnAutoSchema) {add_op = coll1->add(doc.dump(), CREATE);ASSERT_TRUE(add_op.ok());- auto results = coll1->search("org", {"title"}, "", {"org_name"}, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ auto results = coll1->search("org", {"title"}, "", {"org_name"}, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(2, results["hits"].size());ASSERT_EQ("Walmart", results["hits"][0]["document"]["org_name"].get<std::string>());@@ -695,7 +695,7 @@ TEST_F(CollectionAllFieldsTest, WildcardFacetFieldsOnAutoSchema) {add_op = coll1->add(doc.dump(), CREATE);ASSERT_TRUE(add_op.ok());- results = coll1->search("*", {"title"}, "", {"company_name", "org_name"}, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll1->search("*", {"title"}, "", {"company_name", "org_name"}, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(3, results["hits"].size());ASSERT_EQ("company_name", results["facet_counts"][0]["field_name"].get<std::string>());@@ -739,7 +739,7 @@ TEST_F(CollectionAllFieldsTest, WildcardFacetFieldsWithAuoFacetFieldType) {add_op = coll1->add(doc.dump(), CREATE);ASSERT_TRUE(add_op.ok());- auto results = coll1->search("org", {"title"}, "", {"org_name"}, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ auto results = coll1->search("org", {"title"}, "", {"org_name"}, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(2, results["hits"].size());ASSERT_EQ("Walmart", results["hits"][0]["document"]["org_name"].get<std::string>());@@ -778,7 +778,7 @@ TEST_F(CollectionAllFieldsTest, WildcardFacetFieldsWithoutAutoSchema) {add_op = coll1->add(doc.dump(), CREATE);ASSERT_TRUE(add_op.ok());- auto results = coll1->search("org", {"title"}, "", {"org_name"}, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ auto results = coll1->search("org", {"title"}, "", {"org_name"}, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(2, results["hits"].size());ASSERT_EQ("Walmart", results["hits"][0]["document"]["org_name"].get<std::string>());@@ -799,7 +799,7 @@ TEST_F(CollectionAllFieldsTest, WildcardFacetFieldsWithoutAutoSchema) {add_op = coll1->add(doc.dump(), CREATE);ASSERT_TRUE(add_op.ok());- results = coll1->search("*", {"title"}, "", {"company_name", "org_name"}, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll1->search("*", {"title"}, "", {"company_name", "org_name"}, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(3, results["hits"].size());ASSERT_EQ("company_name", results["facet_counts"][0]["field_name"].get<std::string>());@@ -820,7 +820,7 @@ TEST_F(CollectionAllFieldsTest, WildcardFacetFieldsWithoutAutoSchema) {add_op = coll1->add(doc.dump(), CREATE);ASSERT_TRUE(add_op.ok());- auto res_op = coll1->search("*", {"description"}, "", {}, sort_fields, 0, 10, 1, FREQUENCY, false);+ auto res_op = coll1->search("*", {"description"}, "", {}, sort_fields, {0}, 10, 1, FREQUENCY, false);ASSERT_FALSE(res_op.ok());ASSERT_EQ("Could not find a field named `description` in the schema.", res_op.error());@@ -896,17 +896,17 @@ TEST_F(CollectionAllFieldsTest, BothFallbackAndDynamicFields) {auto add_op = coll1->add(doc.dump(), CREATE);ASSERT_TRUE(add_op.ok());- auto res_op = coll1->search("Amazon", {"org_name"}, "", {"org_name"}, sort_fields, 0, 10, 1, FREQUENCY, false);+ auto res_op = coll1->search("Amazon", {"org_name"}, "", {"org_name"}, sort_fields, {0}, 10, 1, FREQUENCY, false);ASSERT_FALSE(res_op.ok());ASSERT_EQ("Could not find a facet field named `org_name` in the schema.", res_op.error());- auto results = coll1->search("Amazon", {"org_name"}, "", {"org_year"}, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ auto results = coll1->search("Amazon", {"org_name"}, "", {"org_year"}, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());- res_op = coll1->search("fizzbuzz", {"rand_str"}, "", {"rand_str"}, sort_fields, 0, 10, 1, FREQUENCY, false);+ res_op = coll1->search("fizzbuzz", {"rand_str"}, "", {"rand_str"}, sort_fields, {0}, 10, 1, FREQUENCY, false);ASSERT_EQ("Could not find a facet field named `rand_str` in the schema.", res_op.error());- results = coll1->search("fizzbuzz", {"rand_str"}, "", {"org_year"}, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll1->search("fizzbuzz", {"rand_str"}, "", {"org_year"}, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());collectionManager.drop_collection("coll1");@@ -965,11 +965,11 @@ TEST_F(CollectionAllFieldsTest, DoNotIndexFieldMarkedAsNonIndex) {ASSERT_EQ(0, coll1->_get_indexes()[0]->_get_search_index().count("post"));- auto res_op = coll1->search("Amazon", {"description_txt"}, "", {}, sort_fields, 0, 10, 1, FREQUENCY, false);+ auto res_op = coll1->search("Amazon", {"description_txt"}, "", {}, sort_fields, {0}, 10, 1, FREQUENCY, false);ASSERT_FALSE(res_op.ok());ASSERT_EQ("Could not find a field named `description_txt` in the schema.", res_op.error());- res_op = coll1->search("Amazon", {"post"}, "", {}, sort_fields, 0, 10, 1, FREQUENCY, false);+ res_op = coll1->search("Amazon", {"post"}, "", {}, sort_fields, {0}, 10, 1, FREQUENCY, false);ASSERT_FALSE(res_op.ok());ASSERT_EQ("Field `post` is marked as a non-indexed field in the schema.", res_op.error());@@ -980,7 +980,7 @@ TEST_F(CollectionAllFieldsTest, DoNotIndexFieldMarkedAsNonIndex) {ASSERT_EQ(0, coll1->_get_indexes()[0]->_get_search_index().count("post"));- auto res = coll1->search("Amazon", {"company_name"}, "", {}, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ auto res = coll1->search("Amazon", {"company_name"}, "", {}, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ("Some post updated.", res["hits"][0]["document"]["post"].get<std::string>());// try to delete doc with non-indexable field@@ -988,7 +988,7 @@ TEST_F(CollectionAllFieldsTest, DoNotIndexFieldMarkedAsNonIndex) {ASSERT_TRUE(del_op.ok());// facet search should also be disabled- auto fs_op = coll1->search("Amazon", {"company_name"}, "", {"description_txt"}, sort_fields, 0, 10, 1, FREQUENCY, false);+ auto fs_op = coll1->search("Amazon", {"company_name"}, "", {"description_txt"}, sort_fields, {0}, 10, 1, FREQUENCY, false);ASSERT_FALSE(fs_op.ok());ASSERT_EQ("Could not find a facet field named `description_txt` in the schema.", fs_op.error());diff --git a/test/collection_faceting_test.cpp b/test/collection_faceting_test.cppindex 407b5c53..bfbcb1ca 100644--- a/test/collection_faceting_test.cpp+++ b/test/collection_faceting_test.cpp@@ -68,7 +68,7 @@ TEST_F(CollectionFacetingTest, FacetCounts) {std::vector<std::string> facets = {"tags"};// single facet with no filters- nlohmann::json results = coll_array_fields->search("Jeremy", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ nlohmann::json results = coll_array_fields->search("Jeremy", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(5, results["hits"].size());ASSERT_EQ(1, results["facet_counts"].size());@@ -90,7 +90,7 @@ TEST_F(CollectionFacetingTest, FacetCounts) {ASSERT_EQ(1, (int) results["facet_counts"][0]["counts"][3]["count"]);// facet with facet count limit- results = coll_array_fields->search("Jeremy", query_fields, "", facets, sort_fields, 0, 10, 1,+ results = coll_array_fields->search("Jeremy", query_fields, "", facets, sort_fields, {0}, 10, 1,FREQUENCY, false, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 2).get();ASSERT_EQ(5, results["hits"].size());@@ -109,7 +109,7 @@ TEST_F(CollectionFacetingTest, FacetCounts) {facets.clear();facets.push_back("tags");facets.push_back("name_facet");- results = coll_array_fields->search("Jeremy", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(5, results["hits"].size());ASSERT_EQ(2, results["facet_counts"].size());@@ -124,7 +124,7 @@ TEST_F(CollectionFacetingTest, FacetCounts) {// facet with filtersfacets.clear();facets.push_back("tags");- results = coll_array_fields->search("Jeremy", query_fields, "age: >24", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "age: >24", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(3, results["hits"].size());ASSERT_EQ(1, results["facet_counts"].size());@@ -143,7 +143,7 @@ TEST_F(CollectionFacetingTest, FacetCounts) {// facet with wildcard queryfacets.clear();facets.push_back("tags");- results = coll_array_fields->search("*", query_fields, "age: >24", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("*", query_fields, "age: >24", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(3, results["hits"].size());ASSERT_EQ(1, results["facet_counts"].size());@@ -160,7 +160,7 @@ TEST_F(CollectionFacetingTest, FacetCounts) {ASSERT_STREQ("FINE PLATINUM", results["facet_counts"][0]["counts"][3]["value"].get<std::string>().c_str());// facet with facet filter query (allows typo correction!)- results = coll_array_fields->search("*", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY,+ results = coll_array_fields->search("*", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, " tags : sliver").get();@@ -172,7 +172,7 @@ TEST_F(CollectionFacetingTest, FacetCounts) {ASSERT_STREQ("silver", results["facet_counts"][0]["counts"][0]["value"].get<std::string>().c_str());// facet with facet filter query matching 2 tokens- results = coll_array_fields->search("*", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY,+ results = coll_array_fields->search("*", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "tags: fxne aluminium").get();@@ -184,7 +184,7 @@ TEST_F(CollectionFacetingTest, FacetCounts) {ASSERT_STREQ("FINE PLATINUM", results["facet_counts"][0]["counts"][0]["value"].get<std::string>().c_str());// facet with facet filter query matching first token of an array- results = coll_array_fields->search("*", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY,+ results = coll_array_fields->search("*", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "tags: fine").get();@@ -196,7 +196,7 @@ TEST_F(CollectionFacetingTest, FacetCounts) {ASSERT_STREQ("FINE PLATINUM", results["facet_counts"][0]["counts"][0]["value"].get<std::string>().c_str());// facet with facet filter query matching second token of an array- results = coll_array_fields->search("*", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY,+ results = coll_array_fields->search("*", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "tags: pltinum").get();@@ -208,7 +208,7 @@ TEST_F(CollectionFacetingTest, FacetCounts) {ASSERT_STREQ("FINE PLATINUM", results["facet_counts"][0]["counts"][0]["value"].get<std::string>().c_str());// facet query on an integer field- results = coll_array_fields->search("*", query_fields, "", {"age"}, sort_fields, 0, 10, 1, FREQUENCY,+ results = coll_array_fields->search("*", query_fields, "", {"age"}, sort_fields, {0}, 10, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "age: 2").get();@@ -225,7 +225,7 @@ TEST_F(CollectionFacetingTest, FacetCounts) {ASSERT_STREQ("<mark>2</mark>4", results["facet_counts"][0]["counts"][1]["highlighted"].get<std::string>().c_str());// facet on a float field without query to check on stats- results = coll_array_fields->search("*", query_fields, "", {"rating"}, sort_fields, 0, 10, 1, FREQUENCY,+ results = coll_array_fields->search("*", query_fields, "", {"rating"}, sort_fields, {0}, 10, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "").get();@@ -236,7 +236,7 @@ TEST_F(CollectionFacetingTest, FacetCounts) {ASSERT_FLOAT_EQ(24.400999426841736, results["facet_counts"][0]["stats"]["sum"].get<double>());// facet query on a float field- results = coll_array_fields->search("*", query_fields, "", {"rating"}, sort_fields, 0, 10, 1, FREQUENCY,+ results = coll_array_fields->search("*", query_fields, "", {"rating"}, sort_fields, {0}, 10, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "rating: 7").get();@@ -256,7 +256,7 @@ TEST_F(CollectionFacetingTest, FacetCounts) {// facet query on an array integer field- results = coll_array_fields->search("*", query_fields, "", {"timestamps"}, sort_fields, 0, 10, 1, FREQUENCY,+ results = coll_array_fields->search("*", query_fields, "", {"timestamps"}, sort_fields, {0}, 10, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "timestamps: 142189002").get();@@ -276,7 +276,7 @@ TEST_F(CollectionFacetingTest, FacetCounts) {ASSERT_FLOAT_EQ(1106321222.0, results["facet_counts"][0]["stats"]["avg"].get<double>());// facet query that does not match any indexed value- results = coll_array_fields->search("*", query_fields, "", {facets}, sort_fields, 0, 10, 1, FREQUENCY,+ results = coll_array_fields->search("*", query_fields, "", {facets}, sort_fields, {0}, 10, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, " tags : notfound").get();@@ -287,14 +287,14 @@ TEST_F(CollectionFacetingTest, FacetCounts) {ASSERT_EQ(0, results["facet_counts"][0]["counts"].size());// empty facet query value should return all facets without any filtering of facets- results = coll_array_fields->search("*", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY,+ results = coll_array_fields->search("*", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "tags: ").get();ASSERT_EQ(5, results["hits"].size());- results = coll_array_fields->search("*", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY,+ results = coll_array_fields->search("*", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "tags:").get();@@ -302,7 +302,7 @@ TEST_F(CollectionFacetingTest, FacetCounts) {ASSERT_EQ(5, results["hits"].size());// bad facet query syntax- auto res_op = coll_array_fields->search("*", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY,+ auto res_op = coll_array_fields->search("*", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "foobar");@@ -311,7 +311,7 @@ TEST_F(CollectionFacetingTest, FacetCounts) {ASSERT_STREQ("Facet query must be in the `facet_field: value` format.", res_op.error().c_str());// unknown facet field- res_op = coll_array_fields->search("*", query_fields, "", {"foobar"}, sort_fields, 0, 10, 1, FREQUENCY,+ res_op = coll_array_fields->search("*", query_fields, "", {"foobar"}, sort_fields, {0}, 10, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "foobar: baz");@@ -320,7 +320,7 @@ TEST_F(CollectionFacetingTest, FacetCounts) {ASSERT_STREQ("Could not find a facet field named `foobar` in the schema.", res_op.error().c_str());// when facet query is given but no facet fields are specified, must return an error message- res_op = coll_array_fields->search("*", query_fields, "", {}, sort_fields, 0, 10, 1, FREQUENCY,+ res_op = coll_array_fields->search("*", query_fields, "", {}, sort_fields, {0}, 10, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "tags: foo");@@ -329,7 +329,7 @@ TEST_F(CollectionFacetingTest, FacetCounts) {ASSERT_STREQ("The `facet_query` parameter is supplied without a `facet_by` parameter.", res_op.error().c_str());// given facet query field must be part of facet fields requested- res_op = coll_array_fields->search("*", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY,+ res_op = coll_array_fields->search("*", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "name_facet: jeremy");@@ -338,7 +338,7 @@ TEST_F(CollectionFacetingTest, FacetCounts) {ASSERT_STREQ("Facet query refers to a facet field `name_facet` that is not part of `facet_by` parameter.", res_op.error().c_str());// facet query with multiple colons- res_op = coll_array_fields->search("*", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY,+ res_op = coll_array_fields->search("*", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "tags:foo:bar");@@ -387,7 +387,7 @@ TEST_F(CollectionFacetingTest, FacetCountsBool) {std::vector<std::string> facets = {"in_stock"};- nlohmann::json results = coll1->search("*", {"title"}, "in_stock:true", facets, sort_fields, 0, 10, 1,+ nlohmann::json results = coll1->search("*", {"title"}, "in_stock:true", facets, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "in_stock:true").get();@@ -426,7 +426,7 @@ TEST_F(CollectionFacetingTest, FacetCountsHighlighting) {std::vector<std::string> facets = {"categories"};- nlohmann::json results = coll1->search("phone", {"categories"}, "", facets, sort_fields, 0, 10, 1,+ nlohmann::json results = coll1->search("phone", {"categories"}, "", facets, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "categories:cell").get();@@ -452,7 +452,7 @@ TEST_F(CollectionFacetingTest, FacetCountsHighlighting) {doc["categories"] = {"Cell Phones", "Unlocked Cell Phones", "All Unlocked Cell Phones" };coll1->add(doc.dump());- results = coll1->search("phone", {"categories"}, "", facets, sort_fields, 0, 10, 1,+ results = coll1->search("phone", {"categories"}, "", facets, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "categories:cell").get();@@ -475,7 +475,7 @@ TEST_F(CollectionFacetingTest, FacetCountsHighlighting) {doc["categories"] = {"Cell Phones", "Cell Phone Accessories", "Cell Phone Cases & Clips"};coll1->add(doc.dump());- results = coll1->search("phone", {"categories"}, "", facets, sort_fields, 0, 10, 1,+ results = coll1->search("phone", {"categories"}, "", facets, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "categories:acces").get();@@ -489,7 +489,7 @@ TEST_F(CollectionFacetingTest, FacetCountsHighlighting) {// ensure that query is NOT case sensitive- results = coll1->search("phone", {"categories"}, "", facets, sort_fields, 0, 10, 1,+ results = coll1->search("phone", {"categories"}, "", facets, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "categories:ACCES").get();@@ -506,7 +506,7 @@ TEST_F(CollectionFacetingTest, FacetCountsHighlighting) {doc["categories"] = {"Cell Phones", "Cell Phone Accessories", "Cellophanes"};coll1->add(doc.dump());- results = coll1->search("phone", {"categories"}, "", facets, sort_fields, 0, 10, 1,+ results = coll1->search("phone", {"categories"}, "", facets, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "categories:cell ph").get();@@ -520,7 +520,7 @@ TEST_F(CollectionFacetingTest, FacetCountsHighlighting) {// facet query longer than a token is correctly matched with typo tolerance// also ensure that setting per_page = 0 works fine- results = coll1->search("phone", {"categories"}, "", facets, sort_fields, 0, 0, 1,+ results = coll1->search("phone", {"categories"}, "", facets, sort_fields, {0}, 0, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "categories:cellx").get();@@ -564,7 +564,7 @@ TEST_F(CollectionFacetingTest, FacetStatOnFloatFields) {query_fields = {"title"};std::vector<std::string> facets;- auto res_op = coll_float_fields->search("Jeremy", query_fields, "", {"average"}, sort_fields_desc, 0, 10,+ auto res_op = coll_float_fields->search("Jeremy", query_fields, "", {"average"}, sort_fields_desc, {0}, 10,1, FREQUENCY, false);auto results = res_op.get();@@ -577,7 +577,7 @@ TEST_F(CollectionFacetingTest, FacetStatOnFloatFields) {ASSERT_FLOAT_EQ(277.8160007725237, results["facet_counts"][0]["stats"]["sum"].get<double>());ASSERT_FLOAT_EQ(39.68800011036053, results["facet_counts"][0]["stats"]["avg"].get<double>());- results = coll_float_fields->search("*", query_fields, "average:>100", {"average"}, sort_fields_desc, 0, 10,+ results = coll_float_fields->search("*", query_fields, "average:>100", {"average"}, sort_fields_desc, {0}, 10,1, FREQUENCY, false).get();ASSERT_EQ(4, results["facet_counts"][0]["stats"].size());@@ -588,7 +588,7 @@ TEST_F(CollectionFacetingTest, FacetStatOnFloatFields) {// facet filter, though should not be considered when calculating facet stats- results = coll_float_fields->search("*", query_fields, "", {"average"}, sort_fields_desc, 0, 10, 1, FREQUENCY,+ results = coll_float_fields->search("*", query_fields, "", {"average"}, sort_fields_desc, {0}, 10, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(),@@ -631,7 +631,7 @@ TEST_F(CollectionFacetingTest, FacetCountOnSimilarStrings) {std::vector<std::string> facets = {"categories"};- nlohmann::json results = coll1->search("*", {"categories"}, "points:[25, 50]", facets, sort_fields, 0, 10, 1,+ nlohmann::json results = coll1->search("*", {"categories"}, "points:[25, 50]", facets, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10).get();diff --git a/test/collection_filtering_test.cpp b/test/collection_filtering_test.cppindex 9d732e4e..2202be0c 100644--- a/test/collection_filtering_test.cpp+++ b/test/collection_filtering_test.cpp@@ -63,7 +63,7 @@ TEST_F(CollectionFilteringTest, FilterOnTextFields) {query_fields = {"name"};std::vector<std::string> facets;- nlohmann::json results = coll_array_fields->search("Jeremy", query_fields, "tags: gold", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ nlohmann::json results = coll_array_fields->search("Jeremy", query_fields, "tags: gold", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(3, results["hits"].size());std::vector<std::string> ids = {"4", "0", "2"};@@ -75,22 +75,22 @@ TEST_F(CollectionFilteringTest, FilterOnTextFields) {ASSERT_STREQ(id.c_str(), result_id.c_str());}- results = coll_array_fields->search("Jeremy", query_fields, "tags : fine PLATINUM", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "tags : fine PLATINUM", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());// using just ":", filtering should return documents that contain ALL tokens in the filter expression- results = coll_array_fields->search("Jeremy", query_fields, "tags : PLATINUM", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "tags : PLATINUM", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());// no documents contain both "white" and "platinum", so- results = coll_array_fields->search("Jeremy", query_fields, "tags : WHITE PLATINUM", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "tags : WHITE PLATINUM", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(0, results["hits"].size());// with exact match operator (:=) partial matches are not allowed- results = coll_array_fields->search("Jeremy", query_fields, "tags:= PLATINUM", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "tags:= PLATINUM", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(0, results["hits"].size());- results = coll_array_fields->search("Jeremy", query_fields, "tags : bronze", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "tags : bronze", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(2, results["hits"].size());ids = {"4", "2"};@@ -103,7 +103,7 @@ TEST_F(CollectionFilteringTest, FilterOnTextFields) {}// search with a list of tags, also testing extra padding of space- results = coll_array_fields->search("Jeremy", query_fields, "tags: [bronze, silver]", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "tags: [bronze, silver]", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(4, results["hits"].size());ids = {"3", "4", "0", "2"};@@ -116,17 +116,17 @@ TEST_F(CollectionFilteringTest, FilterOnTextFields) {}// need to be exact matches- results = coll_array_fields->search("Jeremy", query_fields, "tags: bronze", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "tags: bronze", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(2, results["hits"].size());// when comparators are used, they should be ignored- results = coll_array_fields->search("Jeremy", query_fields, "tags:<bronze", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "tags:<bronze", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(2, results["hits"].size());- results = coll_array_fields->search("Jeremy", query_fields, "tags:<=BRONZE", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "tags:<=BRONZE", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(2, results["hits"].size());- results = coll_array_fields->search("Jeremy", query_fields, "tags:>BRONZE", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "tags:>BRONZE", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(2, results["hits"].size());collectionManager.drop_collection("coll_array_fields");@@ -165,31 +165,31 @@ TEST_F(CollectionFilteringTest, FacetFieldStringFiltering) {// exact filter on string field must fail when single token is usedfacets.clear();facets.emplace_back("starring");- auto results = coll_str->search("*", query_fields, "starring:= samuel", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ auto results = coll_str->search("*", query_fields, "starring:= samuel", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(0, results["hits"].size());ASSERT_EQ(0, results["found"].get<size_t>());// multiple tokens but with a typo on one of them- results = coll_str->search("*", query_fields, "starring:= ssamuel l. Jackson", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_str->search("*", query_fields, "starring:= ssamuel l. Jackson", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(0, results["hits"].size());ASSERT_EQ(0, results["found"].get<size_t>());// same should succeed when verbatim filter is made- results = coll_str->search("*", query_fields, "starring:= samuel l. Jackson", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_str->search("*", query_fields, "starring:= samuel l. Jackson", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(2, results["hits"].size());ASSERT_EQ(2, results["found"].get<size_t>());// contains filter with a single token should work as well- results = coll_str->search("*", query_fields, "starring: jackson", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_str->search("*", query_fields, "starring: jackson", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(2, results["hits"].size());ASSERT_EQ(2, results["found"].get<size_t>());- results = coll_str->search("*", query_fields, "starring: samuel", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_str->search("*", query_fields, "starring: samuel", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(2, results["hits"].size());ASSERT_EQ(2, results["found"].get<size_t>());// contains when only 1 token so should not match- results = coll_str->search("*", query_fields, "starring: samuel johnson", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_str->search("*", query_fields, "starring: samuel johnson", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(0, results["hits"].size());collectionManager.drop_collection("coll_str");@@ -231,46 +231,46 @@ TEST_F(CollectionFilteringTest, FacetFieldStringArrayFiltering) {// facet with filter on string array field must fail when exact token is usedfacets.clear();facets.push_back("tags");- auto results = coll_array_fields->search("Jeremy", query_fields, "tags:= PLATINUM", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ auto results = coll_array_fields->search("Jeremy", query_fields, "tags:= PLATINUM", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(0, results["hits"].size());ASSERT_EQ(0, results["found"].get<size_t>());- results = coll_array_fields->search("Jeremy", query_fields, "tags:= FINE", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "tags:= FINE", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(0, results["hits"].size());- results = coll_array_fields->search("Jeremy", query_fields, "tags:= FFINE PLATINUM", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "tags:= FFINE PLATINUM", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(0, results["hits"].size());// partial token filter should be made without "=" operator- results = coll_array_fields->search("Jeremy", query_fields, "tags: PLATINUM", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "tags: PLATINUM", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());ASSERT_EQ(1, results["found"].get<size_t>());- results = coll_array_fields->search("Jeremy", query_fields, "tags: FINE", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "tags: FINE", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());ASSERT_EQ(1, results["found"].get<size_t>());// to make tokens match facet value exactly, use "=" operator- results = coll_array_fields->search("Jeremy", query_fields, "tags:= FINE PLATINUM", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "tags:= FINE PLATINUM", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());ASSERT_EQ(1, results["found"].get<size_t>());// don't allow exact filter on non-faceted field- auto res_op = coll_array_fields->search("Jeremy", query_fields, "name:= Jeremy Howard", facets, sort_fields, 0, 10, 1, FREQUENCY, false);+ auto res_op = coll_array_fields->search("Jeremy", query_fields, "name:= Jeremy Howard", facets, sort_fields, {0}, 10, 1, FREQUENCY, false);ASSERT_FALSE(res_op.ok());ASSERT_STREQ("To perform exact filtering, filter field `name` must be a facet field.", res_op.error().c_str());// multi match exact query (OR condition)- results = coll_array_fields->search("Jeremy", query_fields, "tags:= [Gold, bronze]", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "tags:= [Gold, bronze]", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(3, results["hits"].size());ASSERT_EQ(3, results["found"].get<size_t>());- results = coll_array_fields->search("Jeremy", query_fields, "tags:= [Gold, bronze, fine PLATINUM]", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "tags:= [Gold, bronze, fine PLATINUM]", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(4, results["hits"].size());ASSERT_EQ(4, results["found"].get<size_t>());// single array multi match- results = coll_array_fields->search("Jeremy", query_fields, "tags:= [fine PLATINUM]", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "tags:= [fine PLATINUM]", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());ASSERT_EQ(1, results["found"].get<size_t>());@@ -300,11 +300,11 @@ TEST_F(CollectionFilteringTest, FilterOnTextFieldWithColon) {query_fields = {"url"};std::vector<std::string> facets;- auto res = coll1->search("*", query_fields, "url:= https://example.com/1", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ auto res = coll1->search("*", query_fields, "url:= https://example.com/1", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, res["hits"].size());ASSERT_STREQ("1", res["hits"][0]["document"]["id"].get<std::string>().c_str());- res = coll1->search("*", query_fields, "url: https://example.com/1", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ res = coll1->search("*", query_fields, "url: https://example.com/1", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, res["hits"].size());ASSERT_STREQ("1", res["hits"][0]["document"]["id"].get<std::string>().c_str());@@ -340,27 +340,27 @@ TEST_F(CollectionFilteringTest, HandleBadlyFormedFilterQuery) {std::vector<std::string> facets;// when filter field does not exist in the schema- nlohmann::json results = coll_array_fields->search("Jeremy", query_fields, "tagzz: gold", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ nlohmann::json results = coll_array_fields->search("Jeremy", query_fields, "tagzz: gold", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(0, results["hits"].size());// searching using a string for a numeric field- results = coll_array_fields->search("Jeremy", query_fields, "age: abcdef", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "age: abcdef", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(0, results["hits"].size());// searching using a string for a numeric array field- results = coll_array_fields->search("Jeremy", query_fields, "timestamps: abcdef", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "timestamps: abcdef", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(0, results["hits"].size());// malformed k:v syntax- results = coll_array_fields->search("Jeremy", query_fields, "timestamps abcdef", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "timestamps abcdef", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(0, results["hits"].size());// just spaces - must be treated as empty filter- results = coll_array_fields->search("Jeremy", query_fields, " ", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, " ", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(5, results["hits"].size());// wrapping number with quotes- results = coll_array_fields->search("Jeremy", query_fields, "age: '21'", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "age: '21'", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(0, results["hits"].size());collectionManager.drop_collection("coll_array_fields");@@ -395,7 +395,7 @@ TEST_F(CollectionFilteringTest, FilterAndQueryFieldRestrictions) {// query shall be allowed on faceted text fields as wellquery_fields = {"cast"};Option<nlohmann::json> result_op =- coll_mul_fields->search("anton", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY, false);+ coll_mul_fields->search("anton", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY, false);ASSERT_TRUE(result_op.ok());nlohmann::json results = result_op.get();@@ -405,7 +405,7 @@ TEST_F(CollectionFilteringTest, FilterAndQueryFieldRestrictions) {// filtering on string field should be possiblequery_fields = {"title"};- result_op = coll_mul_fields->search("captain", query_fields, "starring: Samuel L. Jackson", facets, sort_fields, 0, 10, 1,+ result_op = coll_mul_fields->search("captain", query_fields, "starring: Samuel L. Jackson", facets, sort_fields, {0}, 10, 1,FREQUENCY, false);ASSERT_EQ(true, result_op.ok());results = result_op.get();@@ -415,60 +415,60 @@ TEST_F(CollectionFilteringTest, FilterAndQueryFieldRestrictions) {// filtering on facet field should be possible (supports partial word search but without typo tolerance)query_fields = {"title"};- result_op = coll_mul_fields->search("*", query_fields, "cast: chris", facets, sort_fields, 0, 10, 1,+ result_op = coll_mul_fields->search("*", query_fields, "cast: chris", facets, sort_fields, {0}, 10, 1,FREQUENCY, false);ASSERT_EQ(true, result_op.ok());results = result_op.get();ASSERT_EQ(3, results["hits"].size());// bad query string- result_op = coll_mul_fields->search("captain", query_fields, "BLAH", facets, sort_fields, 0, 10, 1,+ result_op = coll_mul_fields->search("captain", query_fields, "BLAH", facets, sort_fields, {0}, 10, 1,FREQUENCY, false);ASSERT_EQ(false, result_op.ok());ASSERT_STREQ("Could not parse the filter query.", result_op.error().c_str());// missing field- result_op = coll_mul_fields->search("captain", query_fields, "age: 100", facets, sort_fields, 0, 10, 1,+ result_op = coll_mul_fields->search("captain", query_fields, "age: 100", facets, sort_fields, {0}, 10, 1,FREQUENCY, false);ASSERT_EQ(false, result_op.ok());ASSERT_STREQ("Could not find a filter field named `age` in the schema.", result_op.error().c_str());// bad filter value type- result_op = coll_mul_fields->search("captain", query_fields, "points: \"100\"", facets, sort_fields, 0, 10, 1,+ result_op = coll_mul_fields->search("captain", query_fields, "points: \"100\"", facets, sort_fields, {0}, 10, 1,FREQUENCY, false);ASSERT_EQ(false, result_op.ok());ASSERT_STREQ("Error with filter field `points`: Numerical field has an invalid comparator.", result_op.error().c_str());// bad filter value type - equaling float on an integer field- result_op = coll_mul_fields->search("captain", query_fields, "points: 100.34", facets, sort_fields, 0, 10, 1,+ result_op = coll_mul_fields->search("captain", query_fields, "points: 100.34", facets, sort_fields, {0}, 10, 1,FREQUENCY, false);ASSERT_EQ(false, result_op.ok());ASSERT_STREQ("Error with filter field `points`: Not an int32.", result_op.error().c_str());// bad filter value type - less than float on an integer field- result_op = coll_mul_fields->search("captain", query_fields, "points: <100.0", facets, sort_fields, 0, 10, 1,+ result_op = coll_mul_fields->search("captain", query_fields, "points: <100.0", facets, sort_fields, {0}, 10, 1,FREQUENCY, false);ASSERT_EQ(false, result_op.ok());ASSERT_STREQ("Error with filter field `points`: Not an int32.", result_op.error().c_str());// when an int32 field is queried with a 64-bit number- result_op = coll_mul_fields->search("captain", query_fields, "points: <2230070399", facets, sort_fields, 0, 10, 1,+ result_op = coll_mul_fields->search("captain", query_fields, "points: <2230070399", facets, sort_fields, {0}, 10, 1,FREQUENCY, false);ASSERT_EQ(false, result_op.ok());ASSERT_STREQ("Error with filter field `points`: Not an int32.", result_op.error().c_str());// using a string filter value against an integer field- result_op = coll_mul_fields->search("captain", query_fields, "points: <sdsdfsdf", facets, sort_fields, 0, 10, 1,+ result_op = coll_mul_fields->search("captain", query_fields, "points: <sdsdfsdf", facets, sort_fields, {0}, 10, 1,FREQUENCY, false);ASSERT_EQ(false, result_op.ok());// large negative number- result_op = coll_mul_fields->search("captain", query_fields, "points: >-3230070399", facets, sort_fields, 0, 10, 1,+ result_op = coll_mul_fields->search("captain", query_fields, "points: >-3230070399", facets, sort_fields, {0}, 10, 1,FREQUENCY, false);ASSERT_EQ(false, result_op.ok());// but should allow small negative number- result_op = coll_mul_fields->search("captain", query_fields, "points: >-3230", facets, sort_fields, 0, 10, 1,+ result_op = coll_mul_fields->search("captain", query_fields, "points: >-3230", facets, sort_fields, {0}, 10, 1,FREQUENCY, false);ASSERT_EQ(true, result_op.ok());@@ -513,7 +513,7 @@ TEST_F(CollectionFilteringTest, FilterOnNumericFields) {// Plain search with no filters - results should be sorted by rank fieldsquery_fields = {"name"};std::vector<std::string> facets;- nlohmann::json results = coll_array_fields->search("Jeremy", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ nlohmann::json results = coll_array_fields->search("Jeremy", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(5, results["hits"].size());std::vector<std::string> ids = {"3", "1", "4", "0", "2"};@@ -526,7 +526,7 @@ TEST_F(CollectionFilteringTest, FilterOnNumericFields) {}// Searching on an int32 field- results = coll_array_fields->search("Jeremy", query_fields, "age:>24", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "age:>24", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(3, results["hits"].size());ids = {"3", "1", "4"};@@ -538,21 +538,21 @@ TEST_F(CollectionFilteringTest, FilterOnNumericFields) {ASSERT_STREQ(id.c_str(), result_id.c_str());}- results = coll_array_fields->search("Jeremy", query_fields, "age:>=24", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "age:>=24", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(4, results["hits"].size());- results = coll_array_fields->search("Jeremy", query_fields, "age:24", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "age:24", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());// alternative `:=` syntax- results = coll_array_fields->search("Jeremy", query_fields, "age:=24", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "age:=24", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());- results = coll_array_fields->search("Jeremy", query_fields, "age:= 24", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "age:= 24", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());// Searching a number against an int32 array field- results = coll_array_fields->search("Jeremy", query_fields, "years:>2002", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "years:>2002", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(3, results["hits"].size());ids = {"1", "0", "2"};@@ -563,7 +563,7 @@ TEST_F(CollectionFilteringTest, FilterOnNumericFields) {ASSERT_STREQ(id.c_str(), result_id.c_str());}- results = coll_array_fields->search("Jeremy", query_fields, "years:<1989", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "years:<1989", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());ids = {"3"};@@ -575,7 +575,7 @@ TEST_F(CollectionFilteringTest, FilterOnNumericFields) {}// multiple filters- results = coll_array_fields->search("Jeremy", query_fields, "years:<2005 && years:>1987", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "years:<2005 && years:>1987", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());ids = {"4"};@@ -587,7 +587,7 @@ TEST_F(CollectionFilteringTest, FilterOnNumericFields) {}// multiple search values (works like SQL's IN operator) against a single int field- results = coll_array_fields->search("Jeremy", query_fields, "age:[21, 24, 63]", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "age:[21, 24, 63]", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(3, results["hits"].size());ids = {"3", "0", "2"};@@ -599,11 +599,11 @@ TEST_F(CollectionFilteringTest, FilterOnNumericFields) {}// alternative `:=` syntax- results = coll_array_fields->search("Jeremy", query_fields, "age:= [21, 24, 63]", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "age:= [21, 24, 63]", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(3, results["hits"].size());// multiple search values against an int32 array field - also use extra padding between symbols- results = coll_array_fields->search("Jeremy", query_fields, "years : [ 2015, 1985 , 1999]", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "years : [ 2015, 1985 , 1999]", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(4, results["hits"].size());ids = {"3", "1", "4", "0"};@@ -615,7 +615,7 @@ TEST_F(CollectionFilteringTest, FilterOnNumericFields) {}// searching on an int64 array field - also ensure that padded space causes no issues- results = coll_array_fields->search("Jeremy", query_fields, "timestamps : > 475205222", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "timestamps : > 475205222", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(4, results["hits"].size());ids = {"1", "4", "0", "2"};@@ -628,7 +628,7 @@ TEST_F(CollectionFilteringTest, FilterOnNumericFields) {}// range based filter- results = coll_array_fields->search("Jeremy", query_fields, "age: 21..32", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "age: 21..32", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(3, results["hits"].size());ids = {"4", "0", "2"};@@ -639,10 +639,10 @@ TEST_F(CollectionFilteringTest, FilterOnNumericFields) {ASSERT_STREQ(id.c_str(), result_id.c_str());}- results = coll_array_fields->search("Jeremy", query_fields, "age: 0 .. 100", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "age: 0 .. 100", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(5, results["hits"].size());- results = coll_array_fields->search("Jeremy", query_fields, "age: [21..24, 40..65]", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "age: [21..24, 40..65]", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(4, results["hits"].size());ids = {"3", "1", "0", "2"};@@ -653,7 +653,7 @@ TEST_F(CollectionFilteringTest, FilterOnNumericFields) {ASSERT_STREQ(id.c_str(), result_id.c_str());}- results = coll_array_fields->search("Jeremy", query_fields, "rating: 7.812 .. 9.999", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "rating: 7.812 .. 9.999", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(2, results["hits"].size());ids = {"1", "2"};@@ -664,11 +664,11 @@ TEST_F(CollectionFilteringTest, FilterOnNumericFields) {ASSERT_STREQ(id.c_str(), result_id.c_str());}- results = coll_array_fields->search("Jeremy", query_fields, "rating: [7.812 .. 9.999, 1.05 .. 1.09]", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "rating: [7.812 .. 9.999, 1.05 .. 1.09]", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(3, results["hits"].size());// when filters don't match any record, no results should be returned- results = coll_array_fields->search("Jeremy", query_fields, "timestamps:>1591091288061", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "timestamps:>1591091288061", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(0, results["hits"].size());collectionManager.drop_collection("coll_array_fields");@@ -704,7 +704,7 @@ TEST_F(CollectionFilteringTest, FilterOnFloatFields) {// Plain search with no filters - results should be sorted by rating field DESCquery_fields = {"name"};std::vector<std::string> facets;- nlohmann::json results = coll_array_fields->search("Jeremy", query_fields, "", facets, sort_fields_desc, 0, 10, 1, FREQUENCY, false).get();+ nlohmann::json results = coll_array_fields->search("Jeremy", query_fields, "", facets, sort_fields_desc, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(5, results["hits"].size());std::vector<std::string> ids = {"1", "2", "4", "0", "3"};@@ -717,7 +717,7 @@ TEST_F(CollectionFilteringTest, FilterOnFloatFields) {}// Plain search with no filters - results should be sorted by rating field ASC- results = coll_array_fields->search("Jeremy", query_fields, "", facets, sort_fields_asc, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "", facets, sort_fields_asc, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(5, results["hits"].size());ids = {"3", "0", "4", "2", "1"};@@ -730,7 +730,7 @@ TEST_F(CollectionFilteringTest, FilterOnFloatFields) {}// Searching on a float field, sorted desc by rating- results = coll_array_fields->search("Jeremy", query_fields, "rating:>0.0", facets, sort_fields_desc, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "rating:>0.0", facets, sort_fields_desc, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(4, results["hits"].size());ids = {"1", "2", "4", "0"};@@ -743,7 +743,7 @@ TEST_F(CollectionFilteringTest, FilterOnFloatFields) {}// Searching a float against an float array field- results = coll_array_fields->search("Jeremy", query_fields, "top_3:>7.8", facets, sort_fields_desc, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "top_3:>7.8", facets, sort_fields_desc, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(2, results["hits"].size());ids = {"1", "2"};@@ -755,7 +755,7 @@ TEST_F(CollectionFilteringTest, FilterOnFloatFields) {}// multiple filters- results = coll_array_fields->search("Jeremy", query_fields, "top_3:>7.8 && rating:>7.9", facets, sort_fields_desc, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "top_3:>7.8 && rating:>7.9", facets, sort_fields_desc, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());ids = {"1"};@@ -767,7 +767,7 @@ TEST_F(CollectionFilteringTest, FilterOnFloatFields) {}// multiple search values (works like SQL's IN operator) against a single float field- results = coll_array_fields->search("Jeremy", query_fields, "rating:[1.09, 7.812]", facets, sort_fields_desc, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "rating:[1.09, 7.812]", facets, sort_fields_desc, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(2, results["hits"].size());ids = {"2", "0"};@@ -779,7 +779,7 @@ TEST_F(CollectionFilteringTest, FilterOnFloatFields) {}// multiple search values against a float array field - also use extra padding between symbols- results = coll_array_fields->search("Jeremy", query_fields, "top_3 : [ 5.431, 0.001 , 7.812, 11.992]", facets, sort_fields_desc, 0, 10, 1, FREQUENCY, false).get();+ results = coll_array_fields->search("Jeremy", query_fields, "top_3 : [ 5.431, 0.001 , 7.812, 11.992]", facets, sort_fields_desc, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(3, results["hits"].size());ids = {"2", "4", "0"};@@ -791,13 +791,13 @@ TEST_F(CollectionFilteringTest, FilterOnFloatFields) {}// when filters don't match any record, no results should be returned- auto results_op = coll_array_fields->search("Jeremy", query_fields, "rating:<-2.78", facets, sort_fields_desc, 0, 10, 1, FREQUENCY, false);+ auto results_op = coll_array_fields->search("Jeremy", query_fields, "rating:<-2.78", facets, sort_fields_desc, {0}, 10, 1, FREQUENCY, false);ASSERT_TRUE(results_op.ok());results = results_op.get();ASSERT_EQ(0, results["hits"].size());// rank tokens by default sorting field- results_op = coll_array_fields->search("j", query_fields, "", facets, sort_fields_desc, 0, 10, 1, MAX_SCORE, true);+ results_op = coll_array_fields->search("j", query_fields, "", facets, sort_fields_desc, {0}, 10, 1, MAX_SCORE, true);ASSERT_TRUE(results_op.ok());results = results_op.get();ASSERT_EQ(5, results["hits"].size());@@ -846,20 +846,20 @@ TEST_F(CollectionFilteringTest, FilterOnNegativeNumericalFields) {ASSERT_TRUE(coll1->add(doc.dump()).ok());}- auto results = coll1->search("*", {}, "int32_field:<0", {}, {}, 0, 10, 1, FREQUENCY, true, 10).get();+ auto results = coll1->search("*", {}, "int32_field:<0", {}, {}, {0}, 10, 1, FREQUENCY, true, 10).get();ASSERT_EQ(2, results["found"].get<size_t>());ASSERT_EQ(2, results["hits"].size());ASSERT_EQ("0", results["hits"][0]["document"]["id"].get<std::string>());ASSERT_EQ("2", results["hits"][1]["document"]["id"].get<std::string>());- results = coll1->search("*", {}, "int64_field:<0", {}, {}, 0, 10, 1, FREQUENCY, true, 10).get();+ results = coll1->search("*", {}, "int64_field:<0", {}, {}, {0}, 10, 1, FREQUENCY, true, 10).get();ASSERT_EQ(1, results["found"].get<size_t>());ASSERT_EQ(1, results["hits"].size());ASSERT_EQ("1", results["hits"][0]["document"]["id"].get<std::string>());- results = coll1->search("*", {}, "float_field:<0", {}, {sort_by("float_field", "desc")}, 0, 10, 1, FREQUENCY,+ results = coll1->search("*", {}, "float_field:<0", {}, {sort_by("float_field", "desc")}, {0}, 10, 1, FREQUENCY,true, 10).get();ASSERT_EQ(2, results["found"].get<size_t>());@@ -900,7 +900,7 @@ TEST_F(CollectionFilteringTest, ComparatorsOnMultiValuedNumericalField) {query_fields = {"name"};std::vector<std::string> facets;nlohmann::json results = coll_array_fields->search("Jeremy", query_fields, "age: [24, >32]",- facets, sort_fields_desc, 0, 10, 1,FREQUENCY, false).get();+ facets, sort_fields_desc, {0}, 10, 1,FREQUENCY, false).get();ASSERT_EQ(3, results["hits"].size());@@ -916,7 +916,7 @@ TEST_F(CollectionFilteringTest, ComparatorsOnMultiValuedNumericalField) {// with <= and >=results = coll_array_fields->search("Jeremy", query_fields, "age: [<=24, >=44]",- facets, sort_fields_desc, 0, 10, 1,FREQUENCY, false).get();+ facets, sort_fields_desc, {0}, 10, 1,FREQUENCY, false).get();ASSERT_EQ(4, results["hits"].size());@@ -977,7 +977,7 @@ TEST_F(CollectionFilteringTest, GeoPointFiltering) {// pick a location close to only the Sacre Coeurauto results = coll1->search("*",{}, "loc: (48.90615915923891, 2.3435897727061175, 3 km)",- {}, {}, 0, 10, 1, FREQUENCY).get();+ {}, {}, {0}, 10, 1, FREQUENCY).get();ASSERT_EQ(1, results["found"].get<size_t>());ASSERT_EQ(1, results["hits"].size());@@ -987,7 +987,7 @@ TEST_F(CollectionFilteringTest, GeoPointFiltering) {// pick location close to none of the spotsresults = coll1->search("*",{}, "loc: (48.910544830985785, 2.337218333651177, 2 km)",- {}, {}, 0, 10, 1, FREQUENCY).get();+ {}, {}, {0}, 10, 1, FREQUENCY).get();ASSERT_EQ(0, results["found"].get<size_t>());@@ -995,7 +995,7 @@ TEST_F(CollectionFilteringTest, GeoPointFiltering) {results = coll1->search("*",{}, "loc: (48.910544830985785, 2.337218333651177, 20 km)",- {}, {}, 0, 10, 1, FREQUENCY).get();+ {}, {}, {0}, 10, 1, FREQUENCY).get();ASSERT_EQ(10, results["found"].get<size_t>());@@ -1003,7 +1003,7 @@ TEST_F(CollectionFilteringTest, GeoPointFiltering) {results = coll1->search("*",{}, "loc: (48.85825332869331, 2.303816427653377, 1 mi)",- {}, {}, 0, 10, 1, FREQUENCY).get();+ {}, {}, {0}, 10, 1, FREQUENCY).get();ASSERT_EQ(3, results["found"].get<size_t>());@@ -1062,7 +1062,7 @@ TEST_F(CollectionFilteringTest, GeoPolygonFiltering) {"48.85745408145392, 2.3267084486160856, ""48.859636574404355,2.351469427048221, ""48.87756059389807, 2.3443610121873206)",- {}, {}, 0, 10, 1, FREQUENCY).get();+ {}, {}, {0}, 10, 1, FREQUENCY).get();ASSERT_EQ(3, results["found"].get<size_t>());ASSERT_EQ(3, results["hits"].size());@@ -1106,7 +1106,7 @@ TEST_F(CollectionFilteringTest, FilteringWithPrefixSearch) {// pick a location close to only the Sacre Coeurauto res_op = coll1->search("e",{"title"}, "points: 23",- {}, {}, 0, 10, 1, FREQUENCY, true);+ {}, {}, {0}, 10, 1, FREQUENCY, true);auto results = res_op.get();@@ -1150,7 +1150,7 @@ TEST_F(CollectionFilteringTest, NumericalFilteringWithAnd) {auto results = coll1->search("*",{}, "num_employees:>=100 && num_employees:<=300",- {}, sort_fields, 0, 10, 1, FREQUENCY, true).get();+ {}, sort_fields, {0}, 10, 1, FREQUENCY, true).get();ASSERT_EQ(2, results["found"].get<size_t>());ASSERT_EQ(2, results["hits"].size());@@ -1161,14 +1161,14 @@ TEST_F(CollectionFilteringTest, NumericalFilteringWithAnd) {// when filter number is well below all valuesresults = coll1->search("*",{}, "num_employees:>=100 && num_employees:<=10",- {}, sort_fields, 0, 10, 1, FREQUENCY, true).get();+ {}, sort_fields, {0}, 10, 1, FREQUENCY, true).get();ASSERT_EQ(0, results["found"].get<size_t>());// check boundariesresults = coll1->search("*",{}, "num_employees:>=150 && num_employees:<=250",- {}, sort_fields, 0, 10, 1, FREQUENCY, true).get();+ {}, sort_fields, {0}, 10, 1, FREQUENCY, true).get();ASSERT_EQ(2, results["found"].get<size_t>());ASSERT_STREQ("125", results["hits"][0]["document"]["id"].get<std::string>().c_str());@@ -1176,14 +1176,14 @@ TEST_F(CollectionFilteringTest, NumericalFilteringWithAnd) {results = coll1->search("*",{}, "num_employees:>150 && num_employees:<250",- {}, sort_fields, 0, 10, 1, FREQUENCY, true).get();+ {}, sort_fields, {0}, 10, 1, FREQUENCY, true).get();ASSERT_EQ(0, results["found"].get<size_t>());results = coll1->search("*",{}, "num_employees:>50 && num_employees:<250",- {}, sort_fields, 0, 10, 1, FREQUENCY, true).get();+ {}, sort_fields, {0}, 10, 1, FREQUENCY, true).get();ASSERT_EQ(1, results["found"].get<size_t>());ASSERT_STREQ("125", results["hits"][0]["document"]["id"].get<std::string>().c_str());@@ -1192,7 +1192,7 @@ TEST_F(CollectionFilteringTest, NumericalFilteringWithAnd) {results = coll1->search("*",{}, "num_employees:>50 && num_employees:<=500",- {}, sort_fields, 0, 10, 1, FREQUENCY, true).get();+ {}, sort_fields, {0}, 10, 1, FREQUENCY, true).get();ASSERT_EQ(3, results["found"].get<size_t>());ASSERT_STREQ("125", results["hits"][0]["document"]["id"].get<std::string>().c_str());@@ -1201,7 +1201,7 @@ TEST_F(CollectionFilteringTest, NumericalFilteringWithAnd) {results = coll1->search("*",{}, "num_employees:>=50 && num_employees:<500",- {}, sort_fields, 0, 10, 1, FREQUENCY, true).get();+ {}, sort_fields, {0}, 10, 1, FREQUENCY, true).get();ASSERT_EQ(3, results["found"].get<size_t>());ASSERT_STREQ("123", results["hits"][0]["document"]["id"].get<std::string>().c_str());@@ -1211,7 +1211,7 @@ TEST_F(CollectionFilteringTest, NumericalFilteringWithAnd) {// no matchresults = coll1->search("*",{}, "num_employees:>3000 && num_employees:<10",- {}, sort_fields, 0, 10, 1, FREQUENCY, true).get();+ {}, sort_fields, {0}, 10, 1, FREQUENCY, true).get();ASSERT_EQ(0, results["found"].get<size_t>());@@ -1255,7 +1255,7 @@ TEST_F(CollectionFilteringTest, NumericalFilteringWithArray) {// check equals on a repeating priceauto results = coll1->search("*",{}, "prices:1",- {}, {}, 0, 10, 1, FREQUENCY, true).get();+ {}, {}, {0}, 10, 1, FREQUENCY, true).get();ASSERT_EQ(4, results["found"].get<size_t>());ASSERT_EQ(4, results["hits"].size());@@ -1264,28 +1264,28 @@ TEST_F(CollectionFilteringTest, NumericalFilteringWithArray) {results = coll1->search("*",{}, "prices:>=1",- {}, {}, 0, 10, 1, FREQUENCY, true).get();+ {}, {}, {0}, 10, 1, FREQUENCY, true).get();ASSERT_EQ(4, results["found"].get<size_t>());ASSERT_EQ(4, results["hits"].size());results = coll1->search("*",{}, "prices:>=2",- {}, {}, 0, 10, 1, FREQUENCY, true).get();+ {}, {}, {0}, 10, 1, FREQUENCY, true).get();ASSERT_EQ(3, results["found"].get<size_t>());ASSERT_EQ(3, results["hits"].size());results = coll1->search("*",{}, "prices:<4",- {}, {}, 0, 10, 1, FREQUENCY, true).get();+ {}, {}, {0}, 10, 1, FREQUENCY, true).get();ASSERT_EQ(4, results["found"].get<size_t>());ASSERT_EQ(4, results["hits"].size());results = coll1->search("*",{}, "prices:<=2",- {}, {}, 0, 10, 1, FREQUENCY, true).get();+ {}, {}, {0}, 10, 1, FREQUENCY, true).get();ASSERT_EQ(4, results["found"].get<size_t>());ASSERT_EQ(4, results["hits"].size());@@ -1323,7 +1323,7 @@ TEST_F(CollectionFilteringTest, NegationOperatorBasics) {ASSERT_TRUE(coll1->add(doc.dump()).ok());}- auto results = coll1->search("*", {"artist"}, "artist:- Michael Jackson", {}, {}, 0, 10, 1, FREQUENCY, true, 10).get();+ auto results = coll1->search("*", {"artist"}, "artist:- Michael Jackson", {}, {}, {0}, 10, 1, FREQUENCY, true, 10).get();ASSERT_EQ(3, results["found"].get<size_t>());@@ -1331,14 +1331,14 @@ TEST_F(CollectionFilteringTest, NegationOperatorBasics) {ASSERT_STREQ("2", results["hits"][1]["document"]["id"].get<std::string>().c_str());ASSERT_STREQ("0", results["hits"][2]["document"]["id"].get<std::string>().c_str());- results = coll1->search("*", {"artist"}, "artist:- Michael Jackson && points: >0", {}, {}, 0, 10, 1, FREQUENCY, true, 10).get();+ results = coll1->search("*", {"artist"}, "artist:- Michael Jackson && points: >0", {}, {}, {0}, 10, 1, FREQUENCY, true, 10).get();ASSERT_EQ(2, results["found"].get<size_t>());ASSERT_STREQ("3", results["hits"][0]["document"]["id"].get<std::string>().c_str());ASSERT_STREQ("2", results["hits"][1]["document"]["id"].get<std::string>().c_str());// negation operation on multiple values- results = coll1->search("*", {"artist"}, "artist:- [Michael Jackson, Taylor Swift]", {}, {}, 0, 10, 1, FREQUENCY, true, 10).get();+ results = coll1->search("*", {"artist"}, "artist:- [Michael Jackson, Taylor Swift]", {}, {}, {0}, 10, 1, FREQUENCY, true, 10).get();ASSERT_EQ(1, results["found"].get<size_t>());ASSERT_STREQ("3", results["hits"][0]["document"]["id"].get<std::string>().c_str());@@ -1374,26 +1374,26 @@ TEST_F(CollectionFilteringTest, FilterStringsWithComma) {ASSERT_TRUE(coll1->add(doc.dump()).ok());}- auto results = coll1->search("*", {"place"}, "place:= St. John's Cathedral, Denver, Colorado", {}, {}, 0, 10, 1,+ auto results = coll1->search("*", {"place"}, "place:= St. John's Cathedral, Denver, Colorado", {}, {}, {0}, 10, 1,FREQUENCY, true, 10).get();ASSERT_EQ(1, results["found"].get<size_t>());ASSERT_STREQ("0", results["hits"][0]["document"]["id"].get<std::string>().c_str());- results = coll1->search("*", {"place"}, "place:= [`St. John's Cathedral, Denver, Colorado`]", {}, {}, 0, 10, 1,+ results = coll1->search("*", {"place"}, "place:= [`St. John's Cathedral, Denver, Colorado`]", {}, {}, {0}, 10, 1,FREQUENCY, true, 10).get();ASSERT_EQ(1, results["found"].get<size_t>());ASSERT_STREQ("0", results["hits"][0]["document"]["id"].get<std::string>().c_str());- results = coll1->search("*", {"place"}, "place:= [`St. John's Cathedral, Denver, Colorado`, `St. Patrick's Cathedral, Manhattan`]", {}, {}, 0, 10, 1,+ results = coll1->search("*", {"place"}, "place:= [`St. John's Cathedral, Denver, Colorado`, `St. Patrick's Cathedral, Manhattan`]", {}, {}, {0}, 10, 1,FREQUENCY, true, 10).get();ASSERT_EQ(2, results["found"].get<size_t>());ASSERT_STREQ("2", results["hits"][0]["document"]["id"].get<std::string>().c_str());ASSERT_STREQ("0", results["hits"][1]["document"]["id"].get<std::string>().c_str());- results = coll1->search("*", {"place"}, "place: [`Cathedral, Denver, Colorado`]", {}, {}, 0, 10, 1,+ results = coll1->search("*", {"place"}, "place: [`Cathedral, Denver, Colorado`]", {}, {}, {0}, 10, 1,FREQUENCY, true, 10).get();ASSERT_EQ(1, results["found"].get<size_t>());diff --git a/test/collection_grouping_test.cpp b/test/collection_grouping_test.cppindex c226383d..6d84a682 100644--- a/test/collection_grouping_test.cpp+++ b/test/collection_grouping_test.cpp@@ -61,7 +61,7 @@ protected:TEST_F(CollectionGroupingTest, GroupingBasics) {// group by size (int32)- auto res = coll_group->search("*", {}, "", {"brand"}, {}, 0, 50, 1, FREQUENCY,+ auto res = coll_group->search("*", {}, "", {"brand"}, {}, {0}, 50, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 30, 5,@@ -104,7 +104,7 @@ TEST_F(CollectionGroupingTest, GroupingBasics) {// group by rating (float) and sort by sizestd::vector<sort_by> sort_size = {sort_by("size", "DESC")};- res = coll_group->search("*", {}, "", {"brand"}, sort_size, 0, 50, 1, FREQUENCY,+ res = coll_group->search("*", {}, "", {"brand"}, sort_size, {0}, 50, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "brand: omeg", 30, 5,@@ -144,7 +144,7 @@ TEST_F(CollectionGroupingTest, GroupingBasics) {TEST_F(CollectionGroupingTest, GroupingCompoundKey) {// group by size+brand (int32, string)- auto res = coll_group->search("*", {}, "", {"brand"}, {}, 0, 50, 1, FREQUENCY,+ auto res = coll_group->search("*", {}, "", {"brand"}, {}, {0}, 50, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 30, 5,@@ -191,7 +191,7 @@ TEST_F(CollectionGroupingTest, GroupingCompoundKey) {ASSERT_STREQ("Zeta", res["facet_counts"][0]["counts"][3]["value"].get<std::string>().c_str());// pagination with page=2, per_page=2- res = coll_group->search("*", {}, "", {"brand"}, {}, 0, 2, 2, FREQUENCY,+ res = coll_group->search("*", {}, "", {"brand"}, {}, {0}, 2, 2, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 30, 5,@@ -227,7 +227,7 @@ TEST_F(CollectionGroupingTest, GroupingCompoundKey) {ASSERT_STREQ("Zeta", res["facet_counts"][0]["counts"][3]["value"].get<std::string>().c_str());// respect min and max grouping limit (greater than 0 and less than 99)- auto res_op = coll_group->search("*", {}, "", {"brand"}, {}, 0, 50, 1, FREQUENCY,+ auto res_op = coll_group->search("*", {}, "", {"brand"}, {}, {0}, 50, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "brand: omeg", 30, 5,@@ -237,7 +237,7 @@ TEST_F(CollectionGroupingTest, GroupingCompoundKey) {ASSERT_FALSE(res_op.ok());ASSERT_STREQ("Value of `group_limit` must be between 1 and 99.", res_op.error().c_str());- res_op = coll_group->search("*", {}, "", {"brand"}, {}, 0, 50, 1, FREQUENCY,+ res_op = coll_group->search("*", {}, "", {"brand"}, {}, {0}, 50, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "brand: omeg", 30, 5,@@ -286,7 +286,7 @@ TEST_F(CollectionGroupingTest, GroupingWithMultiFieldRelevance) {}auto results = coll1->search("Dustin Kensrue Down There by the Train",- {"title", "artist"}, "", {}, {}, 0, 10, 1, FREQUENCY,+ {"title", "artist"}, "", {}, {}, {0}, 10, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 30, 5,@@ -314,7 +314,7 @@ TEST_F(CollectionGroupingTest, GroupingWithMultiFieldRelevance) {}TEST_F(CollectionGroupingTest, GroupingWithGropLimitOfOne) {- auto res = coll_group->search("*", {}, "", {"brand"}, {}, 0, 50, 1, FREQUENCY,+ auto res = coll_group->search("*", {}, "", {"brand"}, {}, {0}, 50, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 30, 5,@@ -388,7 +388,7 @@ TEST_F(CollectionGroupingTest, GroupingWithArrayFieldAndOverride) {ASSERT_TRUE(ov1_op.ok());ASSERT_TRUE(ov2_op.ok());- auto res = coll_group->search("shirt", {"title"}, "", {"brand"}, {}, 0, 50, 1, FREQUENCY,+ auto res = coll_group->search("shirt", {"title"}, "", {"brand"}, {}, {0}, 50, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 30, 5,diff --git a/test/collection_locale_test.cpp b/test/collection_locale_test.cppindex a180039e..73c0b8cb 100644--- a/test/collection_locale_test.cpp+++ b/test/collection_locale_test.cpp@@ -60,7 +60,7 @@ TEST_F(CollectionLocaleTest, SearchAgainstThaiText) {}auto results = coll1->search("ลงรถไฟ",- {"title"}, "", {}, {}, 0, 10, 1, FREQUENCY).get();+ {"title"}, "", {}, {}, {0}, 10, 1, FREQUENCY).get();ASSERT_EQ(1, results["found"].get<size_t>());ASSERT_EQ(1, results["hits"].size());@@ -68,7 +68,7 @@ TEST_F(CollectionLocaleTest, SearchAgainstThaiText) {ASSERT_EQ("<mark>ลง</mark>ที่นั่นโดย<mark>รถไฟ</mark>", results["hits"][0]["highlights"][0]["snippet"].get<std::string>());results = coll1->search("ลงรถไฟ downie",- {"title", "artist"}, "", {}, {}, 0, 10, 1, FREQUENCY).get();+ {"title", "artist"}, "", {}, {}, {0}, 10, 1, FREQUENCY).get();ASSERT_EQ(2, results["found"].get<size_t>());ASSERT_EQ(2, results["hits"].size());@@ -78,7 +78,7 @@ TEST_F(CollectionLocaleTest, SearchAgainstThaiText) {ASSERT_EQ("1", results["hits"][1]["document"]["id"].get<std::string>());ASSERT_EQ("Gord <mark>Downie</mark>", results["hits"][1]["highlights"][0]["snippet"].get<std::string>());- results = coll1->search("พกไฟ", {"title", "artist"}, "", {}, {}, 0, 10, 1, FREQUENCY).get();+ results = coll1->search("พกไฟ", {"title", "artist"}, "", {}, {}, {0}, 10, 1, FREQUENCY).get();ASSERT_EQ(1, results["found"].get<size_t>());ASSERT_EQ(1, results["hits"].size());ASSERT_EQ("2", results["hits"][0]["document"]["id"].get<std::string>());@@ -114,7 +114,7 @@ TEST_F(CollectionLocaleTest, SearchAgainstKoreanText) {}auto results = coll1->search("극장판",- {"title"}, "", {}, {}, 0, 10, 1, FREQUENCY).get();+ {"title"}, "", {}, {}, {0}, 10, 1, FREQUENCY).get();ASSERT_EQ(1, results["found"].get<size_t>());ASSERT_EQ(1, results["hits"].size());@@ -122,7 +122,7 @@ TEST_F(CollectionLocaleTest, SearchAgainstKoreanText) {ASSERT_EQ("안녕은하철도999<mark>극장판</mark>", results["hits"][0]["highlights"][0]["snippet"].get<std::string>());results = coll1->search("산악",- {"title", "artist"}, "", {}, {}, 0, 10, 1, FREQUENCY).get();+ {"title", "artist"}, "", {}, {}, {0}, 10, 1, FREQUENCY).get();ASSERT_EQ(1, results["found"].get<size_t>());ASSERT_EQ(1, results["hits"].size());@@ -158,7 +158,7 @@ TEST_F(CollectionLocaleTest, SearchAgainstKoreanTextContainingEnglishChars) {}auto results = coll1->search("위축됐다",- {"title"}, "", {}, {}, 0, 10, 1, FREQUENCY).get();+ {"title"}, "", {}, {}, {0}, 10, 1, FREQUENCY).get();ASSERT_EQ(1, results["found"].get<size_t>());ASSERT_EQ(1, results["hits"].size());@@ -166,7 +166,7 @@ TEST_F(CollectionLocaleTest, SearchAgainstKoreanTextContainingEnglishChars) {ASSERT_EQ("개혁 등의 영향으로 11%나 <mark>위축됐다</mark>", results["hits"][0]["highlights"][0]["snippet"].get<std::string>());results = coll1->search("11%",- {"title"}, "", {}, {}, 0, 10, 1, FREQUENCY).get();+ {"title"}, "", {}, {}, {0}, 10, 1, FREQUENCY).get();ASSERT_EQ(1, results["found"].get<size_t>());ASSERT_EQ(1, results["hits"].size());diff --git a/test/collection_manager_test.cpp b/test/collection_manager_test.cppindex e1b99cb9..de847a90 100644--- a/test/collection_manager_test.cpp+++ b/test/collection_manager_test.cpp@@ -231,7 +231,7 @@ TEST_F(CollectionManagerTest, RestoreRecordsOnRestart) {std::vector<std::string> search_fields = {"starring", "title"};std::vector<std::string> facets;- nlohmann::json results = collection1->search("thomas", search_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ nlohmann::json results = collection1->search("thomas", search_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();LOG(INFO) << results;ASSERT_EQ(4, results["hits"].size());@@ -283,7 +283,7 @@ TEST_F(CollectionManagerTest, RestoreRecordsOnRestart) {ASSERT_EQ(0, synonyms.at("id3").root.size());ASSERT_EQ(2, synonyms.at("id3").synonyms.size());- results = collection1->search("thomas", search_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = collection1->search("thomas", search_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(4, results["hits"].size());}@@ -372,7 +372,7 @@ TEST_F(CollectionManagerTest, RestoreAutoSchemaDocsOnRestart) {}// try searching for record with bad data- auto results = restored_coll->search("12345", {"title"}, "", {}, {}, 0, 10, 1, FREQUENCY, false).get();+ auto results = restored_coll->search("12345", {"title"}, "", {}, {}, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());@@ -388,7 +388,7 @@ TEST_F(CollectionManagerTest, RestoreAutoSchemaDocsOnRestart) {ASSERT_EQ(7, restored_coll->get_num_documents());sort_fields = { sort_by("average", "DESC") };- results = restored_coll->search("*", {"title"}, "", {}, {sort_fields}, 0, 10, 1, FREQUENCY, false).get();+ results = restored_coll->search("*", {"title"}, "", {}, {sort_fields}, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(7, results["hits"].size());diff --git a/test/collection_override_test.cpp b/test/collection_override_test.cppindex c7a556d4..b95c0137 100644--- a/test/collection_override_test.cpp+++ b/test/collection_override_test.cpp@@ -78,7 +78,7 @@ TEST_F(CollectionOverrideTest, ExcludeIncludeExactQueryMatch) {std::vector<std::string> facets = {"cast"};- Option<nlohmann::json> res_op = coll_mul_fields->search("of", {"title"}, "", facets, {}, 0, 10);+ Option<nlohmann::json> res_op = coll_mul_fields->search("of", {"title"}, "", facets, {}, {0}, 10);ASSERT_TRUE(res_op.ok());nlohmann::json results = res_op.get();@@ -114,7 +114,7 @@ TEST_F(CollectionOverrideTest, ExcludeIncludeExactQueryMatch) {coll_mul_fields->add_override(override_include);- res_op = coll_mul_fields->search("in", {"title"}, "", {}, {}, 0, 10);+ res_op = coll_mul_fields->search("in", {"title"}, "", {}, {}, {0}, 10);ASSERT_TRUE(res_op.ok());results = res_op.get();@@ -158,7 +158,7 @@ TEST_F(CollectionOverrideTest, ExcludeIncludeExactQueryMatch) {coll_mul_fields->add_override(override_inc_contains);- res_op = coll_mul_fields->search("will smith", {"title"}, "", {}, {}, 0, 10);+ res_op = coll_mul_fields->search("will smith", {"title"}, "", {}, {}, {0}, 10);ASSERT_TRUE(res_op.ok());results = res_op.get();@@ -289,7 +289,7 @@ TEST_F(CollectionOverrideTest, ExcludeIncludeFacetFilterQuery) {coll_mul_fields->add_override(override_include);- auto results = coll_mul_fields->search("not-found", {"title"}, "", {"starring"}, {}, 0, 10, 1, FREQUENCY,+ auto results = coll_mul_fields->search("not-found", {"title"}, "", {"starring"}, {}, {0}, 10, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "starring: will").get();@@ -319,7 +319,7 @@ TEST_F(CollectionOverrideTest, ExcludeIncludeFacetFilterQuery) {coll_mul_fields->add_override(override);- results = coll_mul_fields->search("the", {"title"}, "", {"starring"}, {}, 0, 10, 1, FREQUENCY,+ results = coll_mul_fields->search("the", {"title"}, "", {"starring"}, {}, {0}, 10, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "starring: scott").get();@@ -335,7 +335,7 @@ TEST_F(CollectionOverrideTest, ExcludeIncludeFacetFilterQuery) {// ensure per_page is respected// first with per_page = 0- results = coll_mul_fields->search("the", {"title"}, "", {"starring"}, {}, 0, 0, 1, FREQUENCY,+ results = coll_mul_fields->search("the", {"title"}, "", {"starring"}, {}, {0}, 0, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "starring: scott").get();@@ -348,7 +348,7 @@ TEST_F(CollectionOverrideTest, ExcludeIncludeFacetFilterQuery) {// now with per_page = 1, and an include querycoll_mul_fields->add_override(override_include);- results = coll_mul_fields->search("not-found", {"title"}, "", {"starring"}, {}, 0, 1, 1, FREQUENCY,+ results = coll_mul_fields->search("not-found", {"title"}, "", {"starring"}, {}, {0}, 1, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "").get();@@ -370,7 +370,7 @@ TEST_F(CollectionOverrideTest, IncludeExcludeHitsQuery) {// basic pinning- auto results = coll_mul_fields->search("the", {"title"}, "", {"starring"}, {}, 0, 50, 1, FREQUENCY,+ auto results = coll_mul_fields->search("the", {"title"}, "", {"starring"}, {}, {0}, 50, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "starring: will", 30, 5,@@ -387,7 +387,7 @@ TEST_F(CollectionOverrideTest, IncludeExcludeHitsQuery) {// both pinning and hidingstd::string hidden_hits="11,16";- results = coll_mul_fields->search("the", {"title"}, "", {"starring"}, {}, 0, 50, 1, FREQUENCY,+ results = coll_mul_fields->search("the", {"title"}, "", {"starring"}, {}, {0}, 50, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "starring: will", 30, 5,@@ -401,7 +401,7 @@ TEST_F(CollectionOverrideTest, IncludeExcludeHitsQuery) {// paginating such that pinned hits appear on second pagepinned_hits = "13:4,4:5";- results = coll_mul_fields->search("the", {"title"}, "", {"starring"}, {}, 0, 2, 2, FREQUENCY,+ results = coll_mul_fields->search("the", {"title"}, "", {"starring"}, {}, {0}, 2, 2, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "starring: will", 30, 5,@@ -439,7 +439,7 @@ TEST_F(CollectionOverrideTest, IncludeExcludeHitsQuery) {coll_mul_fields->add_override(override_include);- results = coll_mul_fields->search("the", {"title"}, "", {"starring"}, {}, 0, 50, 1, FREQUENCY,+ results = coll_mul_fields->search("the", {"title"}, "", {"starring"}, {}, {0}, 50, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "starring: will", 30, 5,@@ -459,7 +459,7 @@ TEST_F(CollectionOverrideTest, PinnedHitsSmallerThanPageSize) {// without overrides:// 11, 16, 6, 8, 1, 0, 10, 4, 13, 17- auto results = coll_mul_fields->search("the", {"title"}, "", {"starring"}, {}, 0, 8, 1, FREQUENCY,+ auto results = coll_mul_fields->search("the", {"title"}, "", {"starring"}, {}, {0}, 8, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "starring: will", 30, 5,@@ -477,7 +477,7 @@ TEST_F(CollectionOverrideTest, PinnedHitsSmallerThanPageSize) {std::vector<size_t> expected_ids_p2 = {10, 4};- results = coll_mul_fields->search("the", {"title"}, "", {"starring"}, {}, 0, 8, 2, FREQUENCY,+ results = coll_mul_fields->search("the", {"title"}, "", {"starring"}, {}, {0}, 8, 2, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "starring: will", 30, 5,@@ -497,7 +497,7 @@ TEST_F(CollectionOverrideTest, PinnedHitsLargerThanPageSize) {// pinned hits larger than page size: check that pagination works- auto results = coll_mul_fields->search("the", {"title"}, "", {"starring"}, {}, 0, 2, 1, FREQUENCY,+ auto results = coll_mul_fields->search("the", {"title"}, "", {"starring"}, {}, {0}, 2, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "starring: will", 30, 5,@@ -509,7 +509,7 @@ TEST_F(CollectionOverrideTest, PinnedHitsLargerThanPageSize) {ASSERT_STREQ("6", results["hits"][0]["document"]["id"].get<std::string>().c_str());ASSERT_STREQ("1", results["hits"][1]["document"]["id"].get<std::string>().c_str());- results = coll_mul_fields->search("the", {"title"}, "", {"starring"}, {}, 0, 2, 2, FREQUENCY,+ results = coll_mul_fields->search("the", {"title"}, "", {"starring"}, {}, {0}, 2, 2, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "starring: will", 30, 5,@@ -521,7 +521,7 @@ TEST_F(CollectionOverrideTest, PinnedHitsLargerThanPageSize) {ASSERT_STREQ("16", results["hits"][0]["document"]["id"].get<std::string>().c_str());ASSERT_STREQ("11", results["hits"][1]["document"]["id"].get<std::string>().c_str());- results = coll_mul_fields->search("the", {"title"}, "", {"starring"}, {}, 0, 2, 3, FREQUENCY,+ results = coll_mul_fields->search("the", {"title"}, "", {"starring"}, {}, {0}, 2, 3, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "starring: will", 30, 5,@@ -539,7 +539,7 @@ TEST_F(CollectionOverrideTest, PinnedHitsWhenThereAreNotEnoughResults) {// multiple pinned hits specified, but query produces no result- auto results = coll_mul_fields->search("notfoundquery", {"title"}, "", {"starring"}, {}, 0, 10, 1, FREQUENCY,+ auto results = coll_mul_fields->search("notfoundquery", {"title"}, "", {"starring"}, {}, {0}, 10, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "starring: will", 30, 5,@@ -553,7 +553,7 @@ TEST_F(CollectionOverrideTest, PinnedHitsWhenThereAreNotEnoughResults) {ASSERT_STREQ("11", results["hits"][2]["document"]["id"].get<std::string>().c_str());// multiple pinned hits but only single result- results = coll_mul_fields->search("burgundy", {"title"}, "", {"starring"}, {}, 0, 10, 1, FREQUENCY,+ results = coll_mul_fields->search("burgundy", {"title"}, "", {"starring"}, {}, {0}, 10, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "starring: will", 30, 5,@@ -595,7 +595,7 @@ TEST_F(CollectionOverrideTest, HiddenHitsHidingSingleResult) {}std::string hidden_hits="0";- auto results = coll1->search("the train", {"title"}, "", {}, {}, 0, 50, 1, FREQUENCY,+ auto results = coll1->search("the train", {"title"}, "", {}, {}, {0}, 50, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 30, 5,@@ -605,7 +605,7 @@ TEST_F(CollectionOverrideTest, HiddenHitsHidingSingleResult) {ASSERT_EQ(0, results["found"].get<size_t>());ASSERT_EQ(0, results["hits"].size());- results = coll1->search("the train", {"title"}, "points:0", {}, {}, 0, 50, 1, FREQUENCY,+ results = coll1->search("the train", {"title"}, "points:0", {}, {}, {0}, 50, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 30, 5,@@ -624,7 +624,7 @@ TEST_F(CollectionOverrideTest, PinnedHitsGrouping) {// without any grouping parameter, only the first ID in a position should be picked// and other IDs should appear in their original positions- auto results = coll_mul_fields->search("the", {"title"}, "", {"starring"}, {}, 0, 50, 1, FREQUENCY,+ auto results = coll_mul_fields->search("the", {"title"}, "", {"starring"}, {}, {0}, 50, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "starring: will", 30, 5,@@ -645,7 +645,7 @@ TEST_F(CollectionOverrideTest, PinnedHitsGrouping) {// with grouping- results = coll_mul_fields->search("the", {"title"}, "", {"starring"}, {}, 0, 50, 1, FREQUENCY,+ results = coll_mul_fields->search("the", {"title"}, "", {"starring"}, {}, {0}, 50, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "starring: will", 30, 5,@@ -697,12 +697,12 @@ TEST_F(CollectionOverrideTest, PinnedHitsWithWildCardQuery) {auto pinned_hits = "7:1,4:2";- auto results = coll1->search("*", {"title"}, "", {}, {}, 0, 30, 11, FREQUENCY,+ auto results = coll1->search("*", {"title"}, "", {}, {}, {0}, 30, 11, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 30, 5,"", 10,- pinned_hits, {}, {}, 0, "", "", {}).get();+ pinned_hits, {}, {}, {0}, "", "", {}).get();ASSERT_EQ(311, results["found"].get<size_t>());ASSERT_EQ(11, results["hits"].size());@@ -743,7 +743,7 @@ TEST_F(CollectionOverrideTest, PinnedHitsIdsHavingColon) {std::string pinned_hits_str = "https://example.com/1:1, https://example.com/3:2"; // can have space- auto res_op = coll1->search("*", {"url"}, "", {}, {}, 0, 25, 1, FREQUENCY,+ auto res_op = coll1->search("*", {"url"}, "", {}, {}, {0}, 25, 1, FREQUENCY,false, Index::DROP_TOKENS_THRESHOLD,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 30, 5,diff --git a/test/collection_sorting_test.cpp b/test/collection_sorting_test.cppindex 604e90aa..0d33d129 100644--- a/test/collection_sorting_test.cpp+++ b/test/collection_sorting_test.cpp@@ -60,7 +60,7 @@ TEST_F(CollectionSortingTest, SortingOrder) {query_fields = {"title"};std::vector<std::string> facets;sort_fields = { sort_by("points", "ASC") };- nlohmann::json results = coll_mul_fields->search("the", query_fields, "", facets, sort_fields, 0, 15, 1, FREQUENCY, false).get();+ nlohmann::json results = coll_mul_fields->search("the", query_fields, "", facets, sort_fields, {0}, 15, 1, FREQUENCY, false).get();ASSERT_EQ(10, results["hits"].size());std::vector<std::string> ids = {"17", "13", "10", "4", "0", "1", "8", "6", "16", "11"};@@ -74,7 +74,7 @@ TEST_F(CollectionSortingTest, SortingOrder) {// limiting results to just 5, "ASC" keyword must be case insensitivesort_fields = { sort_by("points", "asc") };- results = coll_mul_fields->search("the", query_fields, "", facets, sort_fields, 0, 5, 1, FREQUENCY, false).get();+ results = coll_mul_fields->search("the", query_fields, "", facets, sort_fields, {0}, 5, 1, FREQUENCY, false).get();ASSERT_EQ(5, results["hits"].size());ids = {"17", "13", "10", "4", "0"};@@ -89,7 +89,7 @@ TEST_F(CollectionSortingTest, SortingOrder) {// descsort_fields = { sort_by("points", "dEsc") };- results = coll_mul_fields->search("the", query_fields, "", facets, sort_fields, 0, 15, 1, FREQUENCY, false).get();+ results = coll_mul_fields->search("the", query_fields, "", facets, sort_fields, {0}, 15, 1, FREQUENCY, false).get();ASSERT_EQ(10, results["hits"].size());ids = {"11", "16", "6", "8", "1", "0", "10", "4", "13", "17"};@@ -104,7 +104,7 @@ TEST_F(CollectionSortingTest, SortingOrder) {// With empty list of sort_by fields:// should be ordered desc on the default sorting field, since the match score will be the same for all records.sort_fields = { };- results = coll_mul_fields->search("of", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_mul_fields->search("of", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(5, results["hits"].size());ids = {"11", "12", "5", "4", "17"};@@ -163,7 +163,7 @@ TEST_F(CollectionSortingTest, NoDefaultSortingField) {infile.close();// without a default sorting field, matches should be sorted by (text_match, seq_id)- auto results = coll1->search("rocket", {"title"}, "", {}, {}, 1, 10, 1, FREQUENCY, false).get();+ auto results = coll1->search("rocket", {"title"}, "", {}, {}, {1}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(5, results["found"]);ASSERT_EQ(5, results["hits"].size());@@ -179,7 +179,7 @@ TEST_F(CollectionSortingTest, NoDefaultSortingField) {auto remove_op = coll1->remove("0");ASSERT_TRUE(remove_op.ok());- results = coll1->search("*", {}, "", {}, {}, 1, 30, 1, FREQUENCY, false).get();+ results = coll1->search("*", {}, "", {}, {}, {1}, 30, 1, FREQUENCY, false).get();ASSERT_EQ(23, results["found"]);ASSERT_EQ(23, results["hits"].size());@@ -221,7 +221,7 @@ TEST_F(CollectionSortingTest, FrequencyOrderedTokensWithoutDefaultSortingField)}}- auto results = coll1->search("e", {"title"}, "", {}, {}, 0, 100, 1, NOT_SET, true).get();+ auto results = coll1->search("e", {"title"}, "", {}, {}, {0}, 100, 1, NOT_SET, true).get();// 11 + 10 + 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2ASSERT_EQ(65, results["found"]);@@ -266,7 +266,7 @@ TEST_F(CollectionSortingTest, Int64AsDefaultSortingField) {query_fields = {"title"};std::vector<std::string> facets;sort_fields = { sort_by("points", "ASC") };- nlohmann::json results = coll_mul_fields->search("foo", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ nlohmann::json results = coll_mul_fields->search("foo", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(4, results["hits"].size());std::vector<std::string> ids = {"3", "1", "0", "2"};@@ -280,7 +280,7 @@ TEST_F(CollectionSortingTest, Int64AsDefaultSortingField) {// DESCsort_fields = { sort_by("points", "desc") };- results = coll_mul_fields->search("foo", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_mul_fields->search("foo", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(4, results["hits"].size());ids = {"2", "0", "1", "3"};@@ -320,7 +320,7 @@ TEST_F(CollectionSortingTest, SortOnFloatFields) {query_fields = {"title"};std::vector<std::string> facets;- nlohmann::json results = coll_float_fields->search("Jeremy", query_fields, "", facets, sort_fields_desc, 0, 10, 1, FREQUENCY, false).get();+ nlohmann::json results = coll_float_fields->search("Jeremy", query_fields, "", facets, sort_fields_desc, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(7, results["hits"].size());std::vector<std::string> ids = {"2", "0", "3", "1", "5", "4", "6"};@@ -333,7 +333,7 @@ TEST_F(CollectionSortingTest, SortOnFloatFields) {}std::vector<sort_by> sort_fields_asc = { sort_by("score", "ASC"), sort_by("average", "ASC") };- results = coll_float_fields->search("Jeremy", query_fields, "", facets, sort_fields_asc, 0, 10, 1, FREQUENCY, false).get();+ results = coll_float_fields->search("Jeremy", query_fields, "", facets, sort_fields_asc, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(7, results["hits"].size());ids = {"6", "4", "5", "1", "3", "0", "2"};@@ -348,7 +348,7 @@ TEST_F(CollectionSortingTest, SortOnFloatFields) {// second field by descstd::vector<sort_by> sort_fields_asc_desc = { sort_by("score", "ASC"), sort_by("average", "DESC") };- results = coll_float_fields->search("Jeremy", query_fields, "", facets, sort_fields_asc_desc, 0, 10, 1, FREQUENCY, false).get();+ results = coll_float_fields->search("Jeremy", query_fields, "", facets, sort_fields_asc_desc, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(7, results["hits"].size());ids = {"5", "4", "6", "1", "3", "0", "2"};@@ -397,7 +397,7 @@ TEST_F(CollectionSortingTest, ThreeSortFieldsLimit) {};query_fields = {"title"};- auto res_op = coll1->search("the", query_fields, "", {}, sort_fields_desc, 0, 10, 1, FREQUENCY, false);+ auto res_op = coll1->search("the", query_fields, "", {}, sort_fields_desc, {0}, 10, 1, FREQUENCY, false);ASSERT_FALSE(res_op.ok());ASSERT_STREQ("Only upto 3 sort_by fields can be specified.", res_op.error().c_str());@@ -438,7 +438,7 @@ TEST_F(CollectionSortingTest, ThreeSortFieldsTextMatchLast) {std::vector<sort_by> sort_fields = { sort_by("popularity", "DESC"), sort_by("points", "DESC"), sort_by(sort_field_const::text_match, "DESC") };auto res = coll1->search("grant",- {"title","artist"}, "", {}, sort_fields, 1, 10, 1, FREQUENCY).get();+ {"title","artist"}, "", {}, sort_fields, {1}, 10, 1, FREQUENCY).get();ASSERT_EQ(2, res["found"].get<size_t>());ASSERT_STREQ("1", res["hits"][0]["document"]["id"].get<std::string>().c_str());@@ -472,7 +472,7 @@ TEST_F(CollectionSortingTest, NegativeInt64Value) {};query_fields = {"title"};- auto res = coll1->search("*", query_fields, "points:>=1577836800", {}, sort_fields_desc, 0, 10, 1, FREQUENCY,+ auto res = coll1->search("*", query_fields, "points:>=1577836800", {}, sort_fields_desc, {0}, 10, 1, FREQUENCY,false).get();ASSERT_EQ(0, res["found"].get<size_t>());@@ -529,7 +529,7 @@ TEST_F(CollectionSortingTest, GeoPointFiltering) {auto results = coll1->search("*",{}, "loc: (48.84442912268208, 2.3490714964332353, 20 km)",- {}, geo_sort_fields, 0, 10, 1, FREQUENCY).get();+ {}, geo_sort_fields, {0}, 10, 1, FREQUENCY).get();ASSERT_EQ(10, results["found"].get<size_t>());@@ -548,7 +548,7 @@ TEST_F(CollectionSortingTest, GeoPointFiltering) {results = coll1->search("*",{}, "",- {}, geo_sort_fields, 0, 10, 1, FREQUENCY).get();+ {}, geo_sort_fields, {0}, 10, 1, FREQUENCY).get();ASSERT_EQ(10, results["found"].get<size_t>());@@ -563,7 +563,7 @@ TEST_F(CollectionSortingTest, GeoPointFiltering) {auto res_op = coll1->search("*",{}, "",- {}, bad_geo_sort_fields, 0, 10, 1, FREQUENCY);+ {}, bad_geo_sort_fields, {0}, 10, 1, FREQUENCY);ASSERT_FALSE(res_op.ok());ASSERT_STREQ("Geopoint sorting field `loc` must be in the `field(24.56,10.45):ASC` format.", res_op.error().c_str());@@ -574,7 +574,7 @@ TEST_F(CollectionSortingTest, GeoPointFiltering) {res_op = coll1->search("*",{}, "",- {}, bad_geo_sort_fields, 0, 10, 1, FREQUENCY);+ {}, bad_geo_sort_fields, {0}, 10, 1, FREQUENCY);ASSERT_FALSE(res_op.ok());ASSERT_STREQ("Geopoint sorting field `loc` must be in the `field(24.56,10.45):ASC` format.", res_op.error().c_str());@@ -585,7 +585,7 @@ TEST_F(CollectionSortingTest, GeoPointFiltering) {res_op = coll1->search("*",{}, "",- {}, bad_geo_sort_fields, 0, 10, 1, FREQUENCY);+ {}, bad_geo_sort_fields, {0}, 10, 1, FREQUENCY);ASSERT_FALSE(res_op.ok());ASSERT_STREQ("Could not find a field named `loc(` in the schema for sorting.", res_op.error().c_str());@@ -596,7 +596,7 @@ TEST_F(CollectionSortingTest, GeoPointFiltering) {res_op = coll1->search("*",{}, "",- {}, bad_geo_sort_fields, 0, 10, 1, FREQUENCY);+ {}, bad_geo_sort_fields, {0}, 10, 1, FREQUENCY);ASSERT_FALSE(res_op.ok());ASSERT_STREQ("Could not find a field named `loc)` in the schema for sorting.", res_op.error().c_str());@@ -607,7 +607,7 @@ TEST_F(CollectionSortingTest, GeoPointFiltering) {res_op = coll1->search("*",{}, "",- {}, bad_geo_sort_fields, 0, 10, 1, FREQUENCY);+ {}, bad_geo_sort_fields, {0}, 10, 1, FREQUENCY);ASSERT_FALSE(res_op.ok());ASSERT_STREQ("Could not find a field named `l` in the schema for sorting.", res_op.error().c_str());diff --git a/test/collection_synonyms_test.cpp b/test/collection_synonyms_test.cppindex 39f4a5ff..2b203b50 100644--- a/test/collection_synonyms_test.cpp+++ b/test/collection_synonyms_test.cpp@@ -304,7 +304,7 @@ TEST_F(CollectionSynonymsTest, OneWaySynonym) {// without synonym- auto res = coll_mul_fields->search("ocean", {"title"}, "", {}, {}, 0, 10).get();+ auto res = coll_mul_fields->search("ocean", {"title"}, "", {}, {}, {0}, 10).get();ASSERT_EQ(0, res["hits"].size());ASSERT_EQ(0, res["found"].get<uint32_t>());@@ -312,7 +312,7 @@ TEST_F(CollectionSynonymsTest, OneWaySynonym) {coll_mul_fields->add_synonym(synonym);- res = coll_mul_fields->search("ocean", {"title"}, "", {}, {}, 0, 10).get();+ res = coll_mul_fields->search("ocean", {"title"}, "", {}, {}, {0}, 10).get();ASSERT_EQ(1, res["hits"].size());ASSERT_EQ(1, res["found"].get<uint32_t>());}@@ -329,13 +329,13 @@ TEST_F(CollectionSynonymsTest, MultiWaySynonym) {// without synonym- auto res = coll_mul_fields->search("homǝland", {"title"}, "", {}, {}, 0, 10).get();+ auto res = coll_mul_fields->search("homǝland", {"title"}, "", {}, {}, {0}, 10).get();ASSERT_EQ(0, res["hits"].size());ASSERT_EQ(0, res["found"].get<uint32_t>());coll_mul_fields->add_synonym(synonym);- res = coll_mul_fields->search("homǝland", {"title"}, "", {}, {}, 0, 10).get();+ res = coll_mul_fields->search("homǝland", {"title"}, "", {}, {}, {0}, 10).get();ASSERT_EQ(1, res["hits"].size());ASSERT_EQ(1, res["found"].get<uint32_t>());@@ -350,12 +350,12 @@ TEST_F(CollectionSynonymsTest, MultiWaySynonym) {syn_op = synonym_t::parse(syn_json2, synonym2);ASSERT_TRUE(syn_op.ok());- res = coll_mul_fields->search("samuel leroy jackson", {"starring"}, "", {}, {}, 0, 10, 1, FREQUENCY, false, 0).get();+ res = coll_mul_fields->search("samuel leroy jackson", {"starring"}, "", {}, {}, {0}, 10, 1, FREQUENCY, false, 0).get();ASSERT_EQ(0, res["hits"].size());coll_mul_fields->add_synonym(synonym2);- res = coll_mul_fields->search("samuel leroy jackson", {"starring"}, "", {}, {}, 0, 10).get();+ res = coll_mul_fields->search("samuel leroy jackson", {"starring"}, "", {}, {}, {0}, 10).get();ASSERT_EQ(2, res["hits"].size());ASSERT_EQ(2, res["found"].get<uint32_t>());@@ -364,7 +364,7 @@ TEST_F(CollectionSynonymsTest, MultiWaySynonym) {// for now we don't support synonyms on ANY prefix- res = coll_mul_fields->search("ler", {"starring"}, "", {}, {}, 0, 10, 1, FREQUENCY, true).get();+ res = coll_mul_fields->search("ler", {"starring"}, "", {}, {}, {0}, 10, 1, FREQUENCY, true).get();ASSERT_EQ(0, res["hits"].size());ASSERT_EQ(0, res["found"].get<uint32_t>());}@@ -410,7 +410,7 @@ TEST_F(CollectionSynonymsTest, ExactMatchRankedSameAsSynonymMatch) {coll1->add_synonym(synonym);- auto res = coll1->search("laughing", {"title"}, "", {}, {}, 0, 10, 1, FREQUENCY, false, 0).get();+ auto res = coll1->search("laughing", {"title"}, "", {}, {}, {0}, 10, 1, FREQUENCY, false, 0).get();ASSERT_EQ(4, res["hits"].size());ASSERT_EQ(4, res["found"].get<uint32_t>());@@ -464,7 +464,7 @@ TEST_F(CollectionSynonymsTest, SynonymFieldOrdering) {coll1->add_synonym(synonym);- auto res = coll1->search("laughing", {"title", "description"}, "", {}, {}, 0, 10, 1, FREQUENCY, false, 0).get();+ auto res = coll1->search("laughing", {"title", "description"}, "", {}, {}, {0}, 10, 1, FREQUENCY, false, 0).get();ASSERT_EQ(2, res["hits"].size());ASSERT_EQ(2, res["found"].get<uint32_t>());diff --git a/test/collection_test.cpp b/test/collection_test.cppindex 29a069c9..531fcdc0 100644--- a/test/collection_test.cpp+++ b/test/collection_test.cpp@@ -109,7 +109,7 @@ TEST_F(CollectionTest, RetrieveADocumentById) {TEST_F(CollectionTest, ExactSearchShouldBeStable) {std::vector<std::string> facets;- nlohmann::json results = collection->search("the", query_fields, "", facets, sort_fields, 0, 10).get();+ nlohmann::json results = collection->search("the", query_fields, "", facets, sort_fields, {0}, 10).get();ASSERT_EQ(7, results["hits"].size());ASSERT_EQ(7, results["found"].get<int>());@@ -130,7 +130,7 @@ TEST_F(CollectionTest, ExactSearchShouldBeStable) {// check ASC sortingstd::vector<sort_by> sort_fields_asc = { sort_by("points", "ASC") };- results = collection->search("the", query_fields, "", facets, sort_fields_asc, 0, 10).get();+ results = collection->search("the", query_fields, "", facets, sort_fields_asc, {0}, 10).get();ASSERT_EQ(7, results["hits"].size());ASSERT_EQ(7, results["found"].get<int>());@@ -144,14 +144,14 @@ TEST_F(CollectionTest, ExactSearchShouldBeStable) {}// when a query does not return results, hits and found fields should still exist in response- results = collection->search("zxsadqewsad", query_fields, "", facets, sort_fields_asc, 0, 10).get();+ results = collection->search("zxsadqewsad", query_fields, "", facets, sort_fields_asc, {0}, 10).get();ASSERT_EQ(0, results["hits"].size());ASSERT_EQ(0, results["found"].get<int>());}TEST_F(CollectionTest, PhraseSearch) {std::vector<std::string> facets;- nlohmann::json results = collection->search("rocket launch", query_fields, "", facets, sort_fields, 0, 10).get();+ nlohmann::json results = collection->search("rocket launch", query_fields, "", facets, sort_fields, {0}, 10).get();ASSERT_EQ(5, results["hits"].size());ASSERT_EQ(5, results["found"].get<uint32_t>());@@ -180,7 +180,7 @@ TEST_F(CollectionTest, PhraseSearch) {// Check ASC sort orderstd::vector<sort_by> sort_fields_asc = { sort_by(sort_field_const::text_match, "DESC"), sort_by("points", "ASC") };- results = collection->search("rocket launch", query_fields, "", facets, sort_fields_asc, 0, 10).get();+ results = collection->search("rocket launch", query_fields, "", facets, sort_fields_asc, {0}, 10).get();ASSERT_EQ(5, results["hits"].size());ASSERT_EQ(5, results["found"].get<uint32_t>());@@ -194,7 +194,7 @@ TEST_F(CollectionTest, PhraseSearch) {}// Check pagination- results = collection->search("rocket launch", query_fields, "", facets, sort_fields, 0, 3).get();+ results = collection->search("rocket launch", query_fields, "", facets, sort_fields, {0}, 3).get();ASSERT_EQ(3, results["hits"].size());ASSERT_EQ(5, results["found"].get<uint32_t>());@@ -212,7 +212,7 @@ TEST_F(CollectionTest, PhraseSearch) {TEST_F(CollectionTest, SearchWithExcludedTokens) {std::vector<std::string> facets;- nlohmann::json results = collection->search("how -propellants -are", query_fields, "", facets, sort_fields, 0, 10).get();+ nlohmann::json results = collection->search("how -propellants -are", query_fields, "", facets, sort_fields, {0}, 10).get();ASSERT_EQ(2, results["hits"].size());ASSERT_EQ(2, results["found"].get<uint32_t>());@@ -226,12 +226,12 @@ TEST_F(CollectionTest, SearchWithExcludedTokens) {ASSERT_STREQ(id.c_str(), result_id.c_str());}- results = collection->search("-rocket", query_fields, "", facets, sort_fields, 0, 50).get();+ results = collection->search("-rocket", query_fields, "", facets, sort_fields, {0}, 50).get();ASSERT_EQ(21, results["found"].get<uint32_t>());ASSERT_EQ(21, results["hits"].size());- results = collection->search("-rocket -cryovolcanism", query_fields, "", facets, sort_fields, 0, 50).get();+ results = collection->search("-rocket -cryovolcanism", query_fields, "", facets, sort_fields, {0}, 50).get();ASSERT_EQ(20, results["found"].get<uint32_t>());}@@ -239,7 +239,7 @@ TEST_F(CollectionTest, SearchWithExcludedTokens) {TEST_F(CollectionTest, SkipUnindexedTokensDuringPhraseSearch) {// Tokens that are not found in the index should be skippedstd::vector<std::string> facets;- nlohmann::json results = collection->search("DoesNotExist from", query_fields, "", facets, sort_fields, 0, 10).get();+ nlohmann::json results = collection->search("DoesNotExist from", query_fields, "", facets, sort_fields, {0}, 10).get();ASSERT_EQ(2, results["hits"].size());std::vector<std::string> ids = {"2", "17"};@@ -252,7 +252,7 @@ TEST_F(CollectionTest, SkipUnindexedTokensDuringPhraseSearch) {}// with non-zero cost- results = collection->search("DoesNotExist from", query_fields, "", facets, sort_fields, 1, 10).get();+ results = collection->search("DoesNotExist from", query_fields, "", facets, sort_fields, {1}, 10).get();ASSERT_EQ(2, results["hits"].size());for(size_t i = 0; i < results["hits"].size(); i++) {@@ -263,7 +263,7 @@ TEST_F(CollectionTest, SkipUnindexedTokensDuringPhraseSearch) {}// with 2 indexed words- results = collection->search("from DoesNotExist insTruments", query_fields, "", facets, sort_fields, 1, 10).get();+ results = collection->search("from DoesNotExist insTruments", query_fields, "", facets, sort_fields, {1}, 10).get();ASSERT_EQ(2, results["hits"].size());ids = {"2", "17"};@@ -276,11 +276,11 @@ TEST_F(CollectionTest, SkipUnindexedTokensDuringPhraseSearch) {// should not try to drop tokens to expand queryresults.clear();- results = collection->search("the a", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY, false, 10).get();+ results = collection->search("the a", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY, false, 10).get();ASSERT_EQ(9, results["hits"].size());results.clear();- results = collection->search("the a", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY, false, 0).get();+ results = collection->search("the a", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY, false, 0).get();ASSERT_EQ(3, results["hits"].size());ids = {"8", "16", "10"};@@ -292,22 +292,22 @@ TEST_F(CollectionTest, SkipUnindexedTokensDuringPhraseSearch) {}results.clear();- results = collection->search("the a DoesNotExist", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY, false, 0).get();+ results = collection->search("the a DoesNotExist", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY, false, 0).get();ASSERT_EQ(0, results["hits"].size());// with no indexed wordresults.clear();- results = collection->search("DoesNotExist1 DoesNotExist2", query_fields, "", facets, sort_fields, 0, 10).get();+ results = collection->search("DoesNotExist1 DoesNotExist2", query_fields, "", facets, sort_fields, {0}, 10).get();ASSERT_EQ(0, results["hits"].size());results.clear();- results = collection->search("DoesNotExist1 DoesNotExist2", query_fields, "", facets, sort_fields, 2, 10).get();+ results = collection->search("DoesNotExist1 DoesNotExist2", query_fields, "", facets, sort_fields, {2}, 10).get();ASSERT_EQ(0, results["hits"].size());}TEST_F(CollectionTest, PartialPhraseSearch) {std::vector<std::string> facets;- nlohmann::json results = collection->search("rocket research", query_fields, "", facets, sort_fields, 0, 10).get();+ nlohmann::json results = collection->search("rocket research", query_fields, "", facets, sort_fields, {0}, 10).get();ASSERT_EQ(6, results["hits"].size());std::vector<std::string> ids = {"19", "1", "10", "8", "16", "17"};@@ -322,7 +322,7 @@ TEST_F(CollectionTest, PartialPhraseSearch) {TEST_F(CollectionTest, QueryWithTypo) {std::vector<std::string> facets;- nlohmann::json results = collection->search("kind biologcal", query_fields, "", facets, sort_fields, 2, 3).get();+ nlohmann::json results = collection->search("kind biologcal", query_fields, "", facets, sort_fields, {2}, 3).get();ASSERT_EQ(3, results["hits"].size());std::vector<std::string> ids = {"19", "3", "20"};@@ -335,7 +335,7 @@ TEST_F(CollectionTest, QueryWithTypo) {}results.clear();- results = collection->search("fer thx", query_fields, "", facets, sort_fields, 1, 3).get();+ results = collection->search("fer thx", query_fields, "", facets, sort_fields, {1}, 3).get();ids = {"1", "10", "13"};ASSERT_EQ(3, results["hits"].size());@@ -350,7 +350,7 @@ TEST_F(CollectionTest, QueryWithTypo) {TEST_F(CollectionTest, TypoTokenRankedByScoreAndFrequency) {std::vector<std::string> facets;- nlohmann::json results = collection->search("loox", query_fields, "", facets, sort_fields, 1, 2, 1, MAX_SCORE, false).get();+ nlohmann::json results = collection->search("loox", query_fields, "", facets, sort_fields, {1}, 2, 1, MAX_SCORE, false).get();ASSERT_EQ(2, results["hits"].size());std::vector<std::string> ids = {"22", "3"};@@ -361,7 +361,7 @@ TEST_F(CollectionTest, TypoTokenRankedByScoreAndFrequency) {ASSERT_STREQ(id.c_str(), result_id.c_str());}- results = collection->search("loox", query_fields, "", facets, sort_fields, 1, 3, 1, FREQUENCY, false).get();+ results = collection->search("loox", query_fields, "", facets, sort_fields, {1}, 3, 1, FREQUENCY, false).get();ASSERT_EQ(3, results["hits"].size());ids = {"22", "3", "12"};@@ -373,19 +373,19 @@ TEST_F(CollectionTest, TypoTokenRankedByScoreAndFrequency) {}// Check pagination- results = collection->search("loox", query_fields, "", facets, sort_fields, 1, 1, 1, FREQUENCY, false).get();+ results = collection->search("loox", query_fields, "", facets, sort_fields, {1}, 1, 1, FREQUENCY, false).get();ASSERT_EQ(5, results["found"].get<int>());ASSERT_EQ(1, results["hits"].size());std::string solo_id = results["hits"].at(0)["document"]["id"];ASSERT_STREQ("22", solo_id.c_str());- results = collection->search("loox", query_fields, "", facets, sort_fields, 1, 2, 1, FREQUENCY, false).get();+ results = collection->search("loox", query_fields, "", facets, sort_fields, {1}, 2, 1, FREQUENCY, false).get();ASSERT_EQ(5, results["found"].get<int>());ASSERT_EQ(2, results["hits"].size());// Check total ordering- results = collection->search("loox", query_fields, "", facets, sort_fields, 1, 10, 1, FREQUENCY, false).get();+ results = collection->search("loox", query_fields, "", facets, sort_fields, {1}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(5, results["hits"].size());ids = {"22", "3", "12", "23", "24"};@@ -396,7 +396,7 @@ TEST_F(CollectionTest, TypoTokenRankedByScoreAndFrequency) {ASSERT_STREQ(id.c_str(), result_id.c_str());}- results = collection->search("loox", query_fields, "", facets, sort_fields, 1, 10, 1, MAX_SCORE, false).get();+ results = collection->search("loox", query_fields, "", facets, sort_fields, {1}, 10, 1, MAX_SCORE, false).get();ASSERT_EQ(5, results["hits"].size());ids = {"22", "3", "12", "23", "24"};@@ -411,7 +411,7 @@ TEST_F(CollectionTest, TypoTokenRankedByScoreAndFrequency) {TEST_F(CollectionTest, TextContainingAnActualTypo) {// A line contains "ISX" but not "what" - need to ensure that correction to "ISS what" happensstd::vector<std::string> facets;- nlohmann::json results = collection->search("ISX what", query_fields, "", facets, sort_fields, 1, 4, 1, FREQUENCY, false).get();+ nlohmann::json results = collection->search("ISX what", query_fields, "", facets, sort_fields, {1}, 4, 1, FREQUENCY, false).get();ASSERT_EQ(4, results["hits"].size());ASSERT_EQ(13, results["found"].get<uint32_t>());@@ -425,7 +425,7 @@ TEST_F(CollectionTest, TextContainingAnActualTypo) {}// Record containing exact token match should appear first- results = collection->search("ISX", query_fields, "", facets, sort_fields, 1, 10, 1, FREQUENCY, false).get();+ results = collection->search("ISX", query_fields, "", facets, sort_fields, {1}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(8, results["hits"].size());ASSERT_EQ(8, results["found"].get<uint32_t>());@@ -440,7 +440,7 @@ TEST_F(CollectionTest, TextContainingAnActualTypo) {}TEST_F(CollectionTest, Pagination) {- nlohmann::json results = collection->search("the", query_fields, "", {}, sort_fields, 0, 3, 1, FREQUENCY, false).get();+ nlohmann::json results = collection->search("the", query_fields, "", {}, sort_fields, {0}, 3, 1, FREQUENCY, false).get();ASSERT_EQ(3, results["hits"].size());ASSERT_EQ(7, results["found"].get<uint32_t>());@@ -453,7 +453,7 @@ TEST_F(CollectionTest, Pagination) {ASSERT_STREQ(id.c_str(), result_id.c_str());}- results = collection->search("the", query_fields, "", {}, sort_fields, 0, 3, 2, FREQUENCY, false).get();+ results = collection->search("the", query_fields, "", {}, sort_fields, {0}, 3, 2, FREQUENCY, false).get();ASSERT_EQ(3, results["hits"].size());ASSERT_EQ(7, results["found"].get<uint32_t>());@@ -466,7 +466,7 @@ TEST_F(CollectionTest, Pagination) {ASSERT_STREQ(id.c_str(), result_id.c_str());}- results = collection->search("the", query_fields, "", {}, sort_fields, 0, 3, 3, FREQUENCY, false).get();+ results = collection->search("the", query_fields, "", {}, sort_fields, {0}, 3, 3, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());ASSERT_EQ(7, results["found"].get<uint32_t>());@@ -481,14 +481,14 @@ TEST_F(CollectionTest, Pagination) {}TEST_F(CollectionTest, WildcardQuery) {- nlohmann::json results = collection->search("*", query_fields, "points:>0", {}, sort_fields, 0, 3, 1, FREQUENCY,+ nlohmann::json results = collection->search("*", query_fields, "points:>0", {}, sort_fields, {0}, 3, 1, FREQUENCY,false).get();ASSERT_EQ(3, results["hits"].size());ASSERT_EQ(25, results["found"].get<uint32_t>());// when no filter is specified, fall back on default sorting field based catch-all filter- Option<nlohmann::json> results_op = collection->search("*", query_fields, "", {}, sort_fields, 0, 3, 1, FREQUENCY,+ Option<nlohmann::json> results_op = collection->search("*", query_fields, "", {}, sort_fields, {0}, 3, 1, FREQUENCY,false);ASSERT_TRUE(results_op.ok());@@ -497,7 +497,7 @@ TEST_F(CollectionTest, WildcardQuery) {// wildcard query with no filters and ASC sortstd::vector<sort_by> sort_fields = { sort_by("points", "ASC") };- results = collection->search("*", query_fields, "", {}, sort_fields, 0, 3, 1, FREQUENCY, false).get();+ results = collection->search("*", query_fields, "", {}, sort_fields, {0}, 3, 1, FREQUENCY, false).get();ASSERT_EQ(3, results["hits"].size());ASSERT_EQ(25, results["found"].get<uint32_t>());@@ -511,21 +511,21 @@ TEST_F(CollectionTest, WildcardQuery) {}// wildcard query should not require a search field- results_op = collection->search("*", {}, "", {}, sort_fields, 0, 3, 1, FREQUENCY, false);+ results_op = collection->search("*", {}, "", {}, sort_fields, {0}, 3, 1, FREQUENCY, false);ASSERT_TRUE(results_op.ok());results = results_op.get();ASSERT_EQ(3, results["hits"].size());ASSERT_EQ(25, results["found"].get<uint32_t>());// non-wildcard query should require a search field- results_op = collection->search("the", {}, "", {}, sort_fields, 0, 3, 1, FREQUENCY, false);+ results_op = collection->search("the", {}, "", {}, sort_fields, {0}, 3, 1, FREQUENCY, false);ASSERT_FALSE(results_op.ok());ASSERT_STREQ("No search fields specified for the query.", results_op.error().c_str());}TEST_F(CollectionTest, PrefixSearching) {std::vector<std::string> facets;- nlohmann::json results = collection->search("ex", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY, true).get();+ nlohmann::json results = collection->search("ex", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY, true).get();ASSERT_EQ(2, results["hits"].size());std::vector<std::string> ids = {"6", "12"};@@ -536,7 +536,7 @@ TEST_F(CollectionTest, PrefixSearching) {ASSERT_STREQ(id.c_str(), result_id.c_str());}- results = collection->search("ex", query_fields, "", facets, sort_fields, 0, 10, 1, MAX_SCORE, true).get();+ results = collection->search("ex", query_fields, "", facets, sort_fields, {0}, 10, 1, MAX_SCORE, true).get();ASSERT_EQ(2, results["hits"].size());ids = {"6", "12"};@@ -547,7 +547,7 @@ TEST_F(CollectionTest, PrefixSearching) {ASSERT_STREQ(id.c_str(), result_id.c_str());}- results = collection->search("what ex", query_fields, "", facets, sort_fields, 0, 10, 1, MAX_SCORE, true).get();+ results = collection->search("what ex", query_fields, "", facets, sort_fields, {0}, 10, 1, MAX_SCORE, true).get();ASSERT_EQ(9, results["hits"].size());ids = {"6", "12", "19", "22", "13", "8", "15", "24", "21"};@@ -559,7 +559,7 @@ TEST_F(CollectionTest, PrefixSearching) {}// restrict to only 2 results and differentiate between MAX_SCORE and FREQUENCY- results = collection->search("t", query_fields, "", facets, sort_fields, 0, 2, 1, MAX_SCORE, true).get();+ results = collection->search("t", query_fields, "", facets, sort_fields, {0}, 2, 1, MAX_SCORE, true).get();ASSERT_EQ(2, results["hits"].size());ids = {"19", "22"};@@ -570,7 +570,7 @@ TEST_F(CollectionTest, PrefixSearching) {ASSERT_STREQ(id.c_str(), result_id.c_str());}- results = collection->search("t", query_fields, "", facets, sort_fields, 0, 2, 1, FREQUENCY, true).get();+ results = collection->search("t", query_fields, "", facets, sort_fields, {0}, 2, 1, FREQUENCY, true).get();ASSERT_EQ(2, results["hits"].size());ids = {"19", "22"};@@ -582,29 +582,29 @@ TEST_F(CollectionTest, PrefixSearching) {}// only the last token in the query should be used for prefix search - so, "math" should not match "mathematics"- results = collection->search("math fx", query_fields, "", facets, sort_fields, 0, 1, 1, FREQUENCY, true).get();+ results = collection->search("math fx", query_fields, "", facets, sort_fields, {0}, 1, 1, FREQUENCY, true).get();ASSERT_EQ(0, results["hits"].size());// single and double char prefixes should set a ceiling on the num_typos possible- results = collection->search("x", query_fields, "", facets, sort_fields, 2, 2, 1, FREQUENCY, true).get();+ results = collection->search("x", query_fields, "", facets, sort_fields, {2}, 2, 1, FREQUENCY, true).get();ASSERT_EQ(0, results["hits"].size());// prefix with a typo- results = collection->search("late propx", query_fields, "", facets, sort_fields, 2, 1, 1, FREQUENCY, true).get();+ results = collection->search("late propx", query_fields, "", facets, sort_fields, {2}, 1, 1, FREQUENCY, true).get();ASSERT_EQ(1, results["hits"].size());ASSERT_EQ("16", results["hits"].at(0)["document"]["id"]);}TEST_F(CollectionTest, TypoTokensThreshold) {// Query expansion should happen only based on the `typo_tokens_threshold` value- auto results = collection->search("launch", {"title"}, "", {}, sort_fields, 2, 10, 1,+ auto results = collection->search("launch", {"title"}, "", {}, sort_fields, {2}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 5, 5, "", 0).get();ASSERT_EQ(5, results["hits"].size());ASSERT_EQ(5, results["found"].get<size_t>());- results = collection->search("launch", {"title"}, "", {}, sort_fields, 2, 10, 1,+ results = collection->search("launch", {"title"}, "", {}, sort_fields, {2}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 5, 5, "", 10).get();@@ -632,7 +632,7 @@ TEST_F(CollectionTest, MultiOccurrenceString) {coll_multi_string->add(document.dump()).get();query_fields = {"title"};- nlohmann::json results = coll_multi_string->search("the", query_fields, "", {}, sort_fields, 0, 10, 1,+ nlohmann::json results = coll_multi_string->search("the", query_fields, "", {}, sort_fields, {0}, 10, 1,FREQUENCY, false, 0).get();ASSERT_EQ(1, results["hits"].size());collectionManager.drop_collection("coll_multi_string");@@ -664,7 +664,7 @@ TEST_F(CollectionTest, ArrayStringFieldHighlight) {query_fields = {"tags"};std::vector<std::string> facets;- nlohmann::json results = coll_array_text->search("truth about", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY,+ nlohmann::json results = coll_array_text->search("truth about", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY,false, 0).get();ASSERT_EQ(1, results["hits"].size());@@ -691,7 +691,7 @@ TEST_F(CollectionTest, ArrayStringFieldHighlight) {ASSERT_EQ(0, results["hits"][0]["highlights"][0]["indices"][1]);ASSERT_EQ(1, results["hits"][0]["highlights"][0]["indices"][2]);- results = coll_array_text->search("forever truth", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY,+ results = coll_array_text->search("forever truth", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY,false, 0).get();ASSERT_EQ(1, results["hits"].size());@@ -714,7 +714,7 @@ TEST_F(CollectionTest, ArrayStringFieldHighlight) {ASSERT_EQ(1, results["hits"][0]["highlights"][0]["indices"][1]);ASSERT_EQ(2, results["hits"][0]["highlights"][0]["indices"][2]);- results = coll_array_text->search("truth", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY,+ results = coll_array_text->search("truth", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY,false, 0).get();ASSERT_EQ(2, results["hits"].size());@@ -727,12 +727,12 @@ TEST_F(CollectionTest, ArrayStringFieldHighlight) {ASSERT_STREQ(id.c_str(), result_id.c_str());}- results = coll_array_text->search("asdadasd", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY,+ results = coll_array_text->search("asdadasd", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY,false, 0).get();ASSERT_EQ(0, results["hits"].size());query_fields = {"title", "tags"};- results = coll_array_text->search("truth", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY,+ results = coll_array_text->search("truth", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY,false, 0).get();ASSERT_EQ(2, results["hits"].size());ASSERT_EQ(2, results["hits"][0]["highlights"].size());@@ -785,7 +785,7 @@ TEST_F(CollectionTest, ArrayStringFieldHighlight) {ASSERT_EQ(2, results["hits"][1]["highlights"][1]["indices"][1]);// highlight fields must be ordered based on match score- results = coll_array_text->search("amazing movie", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY,+ results = coll_array_text->search("amazing movie", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY,false, 0).get();ASSERT_EQ(1, results["hits"].size());ASSERT_EQ(2, results["hits"][0]["highlights"].size());@@ -808,7 +808,7 @@ TEST_F(CollectionTest, ArrayStringFieldHighlight) {ASSERT_STREQ("amazing", results["hits"][0]["highlights"][1]["matched_tokens"][1].get<std::string>().c_str());// when query tokens are not found in an array field they should be ignored- results = coll_array_text->search("winds", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY,+ results = coll_array_text->search("winds", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY,false, 0).get();ASSERT_EQ(1, results["hits"].size());ASSERT_EQ(1, results["hits"][0]["highlights"].size());@@ -844,7 +844,7 @@ TEST_F(CollectionTest, MultipleFields) {query_fields = {"title", "starring"};std::vector<std::string> facets;- nlohmann::json results = coll_mul_fields->search("Will", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ nlohmann::json results = coll_mul_fields->search("Will", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(4, results["hits"].size());std::vector<std::string> ids = {"3", "2", "1", "0"};@@ -859,7 +859,7 @@ TEST_F(CollectionTest, MultipleFields) {// when "starring" takes higher priority than "title"query_fields = {"starring", "title"};- results = coll_mul_fields->search("thomas", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_mul_fields->search("thomas", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(4, results["hits"].size());ids = {"15", "12", "13", "14"};@@ -872,11 +872,11 @@ TEST_F(CollectionTest, MultipleFields) {}query_fields = {"starring", "title", "cast"};- results = coll_mul_fields->search("ben affleck", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_mul_fields->search("ben affleck", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());query_fields = {"cast"};- results = coll_mul_fields->search("chris", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_mul_fields->search("chris", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(3, results["hits"].size());ids = {"6", "1", "7"};@@ -888,7 +888,7 @@ TEST_F(CollectionTest, MultipleFields) {}query_fields = {"cast"};- results = coll_mul_fields->search("chris pine", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_mul_fields->search("chris pine", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(3, results["hits"].size());ids = {"7", "6", "1"};@@ -901,7 +901,7 @@ TEST_F(CollectionTest, MultipleFields) {// filtering on unfaceted multi-valued string fieldquery_fields = {"title"};- results = coll_mul_fields->search("captain", query_fields, "cast: chris", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_mul_fields->search("captain", query_fields, "cast: chris", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());ids = {"6"};for(size_t i = 0; i < results["hits"].size(); i++) {@@ -915,7 +915,7 @@ TEST_F(CollectionTest, MultipleFields) {query_fields = {"starring", "title", "cast"};facets = {"starring_facet"};- results = coll_mul_fields->search("myers", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_mul_fields->search("myers", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());ids = {"17"};for(size_t i = 0; i < results["hits"].size(); i++) {@@ -962,21 +962,21 @@ TEST_F(CollectionTest, KeywordQueryReturnsResultsBasedOnPerPageParam) {std::vector<std::string> facets;spp::sparse_hash_set<std::string> empty;- nlohmann::json results = coll_mul_fields->search("w", query_fields, "", facets, sort_fields, 0, 3, 1,+ nlohmann::json results = coll_mul_fields->search("w", query_fields, "", facets, sort_fields, {0}, 3, 1,FREQUENCY, true, 1000, empty, empty, 10).get();ASSERT_EQ(3, results["hits"].size());ASSERT_EQ(7, results["found"].get<int>());// cannot fetch more than in-built limit of 250- auto res_op = coll_mul_fields->search("w", query_fields, "", facets, sort_fields, 0, 251, 1,+ auto res_op = coll_mul_fields->search("w", query_fields, "", facets, sort_fields, {0}, 251, 1,FREQUENCY, true, 1000, empty, empty, 10);ASSERT_FALSE(res_op.ok());ASSERT_EQ(422, res_op.code());ASSERT_STREQ("Only upto 250 hits can be fetched per page.", res_op.error().c_str());// when page number is not valid- res_op = coll_mul_fields->search("w", query_fields, "", facets, sort_fields, 0, 10, 0,+ res_op = coll_mul_fields->search("w", query_fields, "", facets, sort_fields, {0}, 10, 0,FREQUENCY, true, 1000, empty, empty, 10);ASSERT_FALSE(res_op.ok());ASSERT_EQ(422, res_op.code());@@ -984,19 +984,19 @@ TEST_F(CollectionTest, KeywordQueryReturnsResultsBasedOnPerPageParam) {// do pagination- results = coll_mul_fields->search("w", query_fields, "", facets, sort_fields, 0, 3, 1,+ results = coll_mul_fields->search("w", query_fields, "", facets, sort_fields, {0}, 3, 1,FREQUENCY, true, 1000, empty, empty, 10).get();ASSERT_EQ(3, results["hits"].size());ASSERT_EQ(7, results["found"].get<int>());- results = coll_mul_fields->search("w", query_fields, "", facets, sort_fields, 0, 3, 2,+ results = coll_mul_fields->search("w", query_fields, "", facets, sort_fields, {0}, 3, 2,FREQUENCY, true, 1000, empty, empty, 10).get();ASSERT_EQ(3, results["hits"].size());ASSERT_EQ(7, results["found"].get<int>());- results = coll_mul_fields->search("w", query_fields, "", facets, sort_fields, 0, 3, 3,+ results = coll_mul_fields->search("w", query_fields, "", facets, sort_fields, {0}, 3, 3,FREQUENCY, true, 1000, empty, empty, 10).get();ASSERT_EQ(1, results["hits"].size());@@ -1045,7 +1045,7 @@ TEST_F(CollectionTest, ImportDocumentsUpsert) {ASSERT_EQ(18, import_response["num_imported"].get<int>());// try searching with filter- auto results = coll_mul_fields->search("*", query_fields, "starring:= [Will Ferrell]", {"starring"}, sort_fields, 0, 30, 1, FREQUENCY, false).get();+ auto results = coll_mul_fields->search("*", query_fields, "starring:= [Will Ferrell]", {"starring"}, sort_fields, {0}, 30, 1, FREQUENCY, false).get();ASSERT_EQ(2, results["hits"].size());// update existing record verbatim@@ -1074,32 +1074,32 @@ TEST_F(CollectionTest, ImportDocumentsUpsert) {}// try with filters again- results = coll_mul_fields->search("*", query_fields, "starring:= [Will Ferrell]", {"starring"}, sort_fields, 0, 30, 1, FREQUENCY, false).get();+ results = coll_mul_fields->search("*", query_fields, "starring:= [Will Ferrell]", {"starring"}, sort_fields, {0}, 30, 1, FREQUENCY, false).get();ASSERT_EQ(2, results["hits"].size());- results = coll_mul_fields->search("*", query_fields, "", {"starring"}, sort_fields, 0, 30, 1, FREQUENCY, false).get();+ results = coll_mul_fields->search("*", query_fields, "", {"starring"}, sort_fields, {0}, 30, 1, FREQUENCY, false).get();ASSERT_EQ(19, results["hits"].size());ASSERT_EQ(19, coll_mul_fields->get_num_documents());- results = coll_mul_fields->search("back again forest", query_fields, "", {"starring"}, sort_fields, 0, 30, 1, FREQUENCY, false).get();+ results = coll_mul_fields->search("back again forest", query_fields, "", {"starring"}, sort_fields, {0}, 30, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());ASSERT_STREQ("Back Again Forest", coll_mul_fields->get("18").get()["title"].get<std::string>().c_str());- results = coll_mul_fields->search("fifth", query_fields, "", {"starring"}, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_mul_fields->search("fifth", query_fields, "", {"starring"}, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(2, results["hits"].size());ASSERT_STREQ("The <mark>Fifth</mark> Harry", results["hits"][0]["highlights"][0]["snippet"].get<std::string>().c_str());ASSERT_STREQ("The Woman in the <mark>Fifth</mark> from Kristin", results["hits"][1]["highlights"][0]["snippet"].get<std::string>().c_str());- results = coll_mul_fields->search("burgundy", query_fields, "", {}, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_mul_fields->search("burgundy", query_fields, "", {}, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(0, results["hits"].size());- results = coll_mul_fields->search("harry", query_fields, "", {}, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_mul_fields->search("harry", query_fields, "", {}, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());- results = coll_mul_fields->search("captain america", query_fields, "", {}, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_mul_fields->search("captain america", query_fields, "", {}, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());ASSERT_EQ(77, results["hits"][0]["document"]["points"].get<size_t>());@@ -1144,7 +1144,7 @@ TEST_F(CollectionTest, ImportDocumentsUpsert) {ASSERT_TRUE(import_response["success"].get<bool>());ASSERT_EQ(1, import_response["num_imported"].get<int>());- results = coll_mul_fields->search("Good Will Hunting", query_fields, "", {"starring"}, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_mul_fields->search("Good Will Hunting", query_fields, "", {"starring"}, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(70, results["hits"][0]["document"]["points"].get<uint32_t>());// updating a document that does not exist should fail, others should succeed@@ -1161,7 +1161,7 @@ TEST_F(CollectionTest, ImportDocumentsUpsert) {ASSERT_STREQ("Could not find a document with id: 20", import_results[0]["error"].get<std::string>().c_str());ASSERT_EQ(404, import_results[0]["code"].get<size_t>());- results = coll_mul_fields->search("wake up harry", query_fields, "", {"starring"}, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_mul_fields->search("wake up harry", query_fields, "", {"starring"}, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(64, results["hits"][0]["document"]["points"].get<uint32_t>());// trying to create documents with existing IDs should fail@@ -1300,9 +1300,9 @@ TEST_F(CollectionTest, ImportDocuments) {query_fields = {"title", "starring"};std::vector<std::string> facets;- auto x = coll_mul_fields->search("Will", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY, false);+ auto x = coll_mul_fields->search("Will", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY, false);- nlohmann::json results = coll_mul_fields->search("Will", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ nlohmann::json results = coll_mul_fields->search("Will", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(4, results["hits"].size());std::vector<std::string> ids = {"3", "2", "1", "0"};@@ -1433,7 +1433,7 @@ TEST_F(CollectionTest, QueryBoolFields) {// Plain search with no filters - results should be sorted correctlyquery_fields = {"title"};std::vector<std::string> facets;- nlohmann::json results = coll_bool->search("the", query_fields, "", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ nlohmann::json results = coll_bool->search("the", query_fields, "", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(5, results["hits"].size());std::vector<std::string> ids = {"1", "3", "4", "9", "2"};@@ -1446,7 +1446,7 @@ TEST_F(CollectionTest, QueryBoolFields) {}// Searching on a bool field- results = coll_bool->search("the", query_fields, "popular:true", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_bool->search("the", query_fields, "popular:true", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(3, results["hits"].size());ids = {"1", "3", "4"};@@ -1459,10 +1459,10 @@ TEST_F(CollectionTest, QueryBoolFields) {}// alternative `:=` syntax- results = coll_bool->search("the", query_fields, "popular:=true", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_bool->search("the", query_fields, "popular:=true", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(3, results["hits"].size());- results = coll_bool->search("the", query_fields, "popular:false", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_bool->search("the", query_fields, "popular:false", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(2, results["hits"].size());ids = {"9", "2"};@@ -1478,13 +1478,13 @@ TEST_F(CollectionTest, QueryBoolFields) {// should be able to filter with an array of boolean valuesOption<nlohmann::json> res_op = coll_bool->search("the", query_fields, "bool_array:[true, false]", facets,- sort_fields, 0, 10, 1, FREQUENCY, false);+ sort_fields, {0}, 10, 1, FREQUENCY, false);ASSERT_TRUE(res_op.ok());results = res_op.get();ASSERT_EQ(5, results["hits"].size());- results = coll_bool->search("the", query_fields, "bool_array: true", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_bool->search("the", query_fields, "bool_array: true", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(4, results["hits"].size());ids = {"1", "4", "9", "2"};@@ -1498,9 +1498,9 @@ TEST_F(CollectionTest, QueryBoolFields) {// should be able to search using array with a single element boolean valueauto res = coll_bool->search("the", query_fields, "bool_array:[true]", facets,- sort_fields, 0, 10, 1, FREQUENCY, false).get();+ sort_fields, {0}, 10, 1, FREQUENCY, false).get();- results = coll_bool->search("the", query_fields, "bool_array: true", facets, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ results = coll_bool->search("the", query_fields, "bool_array: true", facets, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(4, results["hits"].size());for(size_t i = 0; i < results["hits"].size(); i++) {@@ -1543,27 +1543,27 @@ TEST_F(CollectionTest, SearchingWithMissingFields) {std::vector<std::string> facets;std::vector<std::string> query_fields_not_found = {"titlez"};- Option<nlohmann::json> res_op = coll_array_fields->search("the", query_fields_not_found, "", facets, sort_fields, 0, 10);+ Option<nlohmann::json> res_op = coll_array_fields->search("the", query_fields_not_found, "", facets, sort_fields, {0}, 10);ASSERT_FALSE(res_op.ok());ASSERT_EQ(404, res_op.code());ASSERT_STREQ("Could not find a field named `titlez` in the schema.", res_op.error().c_str());// when a query field is an integer field- res_op = coll_array_fields->search("the", {"age"}, "", facets, sort_fields, 0, 10);+ res_op = coll_array_fields->search("the", {"age"}, "", facets, sort_fields, {0}, 10);ASSERT_EQ(400, res_op.code());ASSERT_STREQ("Field `age` should be a string or a string array.", res_op.error().c_str());// when a facet field is not defined in the schema- res_op = coll_array_fields->search("the", {"name"}, "", {"timestamps"}, sort_fields, 0, 10);+ res_op = coll_array_fields->search("the", {"name"}, "", {"timestamps"}, sort_fields, {0}, 10);ASSERT_EQ(404, res_op.code());ASSERT_STREQ("Could not find a facet field named `timestamps` in the schema.", res_op.error().c_str());// when a rank field is not defined in the schema- res_op = coll_array_fields->search("the", {"name"}, "", {}, { sort_by("timestamps", "ASC") }, 0, 10);+ res_op = coll_array_fields->search("the", {"name"}, "", {}, { sort_by("timestamps", "ASC") }, {0}, 10);ASSERT_EQ(404, res_op.code());ASSERT_STREQ("Could not find a field named `timestamps` in the schema for sorting.", res_op.error().c_str());- res_op = coll_array_fields->search("the", {"name"}, "", {}, { sort_by("_rank", "ASC") }, 0, 10);+ res_op = coll_array_fields->search("the", {"name"}, "", {}, { sort_by("_rank", "ASC") }, {0}, 10);ASSERT_EQ(404, res_op.code());ASSERT_STREQ("Could not find a field named `_rank` in the schema for sorting.", res_op.error().c_str());@@ -1680,7 +1680,7 @@ TEST_F(CollectionTest, EmptyIndexShouldNotCrash) {empty_coll = collectionManager.create_collection("empty_coll", 4, fields, "age").get();}- nlohmann::json results = empty_coll->search("a", {"name"}, "", {}, sort_fields, 0, 10, 1, FREQUENCY, false).get();+ nlohmann::json results = empty_coll->search("a", {"name"}, "", {}, sort_fields, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(0, results["hits"].size());collectionManager.drop_collection("empty_coll");}@@ -1775,7 +1775,7 @@ TEST_F(CollectionTest, DeletionOfADocument) {nlohmann::json results;// asserts before removing any record- results = collection_for_del->search("cryogenic", query_fields, "", {}, sort_fields, 0, 5, 1, FREQUENCY, false).get();+ results = collection_for_del->search("cryogenic", query_fields, "", {}, sort_fields, {0}, 5, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());it = store->get_iterator();@@ -1789,16 +1789,16 @@ TEST_F(CollectionTest, DeletionOfADocument) {// actually remove a record nowcollection_for_del->remove("1");- results = collection_for_del->search("cryogenic", query_fields, "", {}, sort_fields, 0, 5, 1, FREQUENCY, false).get();+ results = collection_for_del->search("cryogenic", query_fields, "", {}, sort_fields, {0}, 5, 1, FREQUENCY, false).get();ASSERT_EQ(0, results["hits"].size());ASSERT_EQ(0, results["found"]);- results = collection_for_del->search("archives", query_fields, "", {}, sort_fields, 0, 5, 1, FREQUENCY, false).get();+ results = collection_for_del->search("archives", query_fields, "", {}, sort_fields, {0}, 5, 1, FREQUENCY, false).get();ASSERT_EQ(1, results["hits"].size());ASSERT_EQ(1, results["found"]);collection_for_del->remove("foo"); // custom id record- results = collection_for_del->search("martian", query_fields, "", {}, sort_fields, 0, 5, 1, FREQUENCY, false).get();+ results = collection_for_del->search("martian", query_fields, "", {}, sort_fields, {0}, 5, 1, FREQUENCY, false).get();ASSERT_EQ(0, results["hits"].size());ASSERT_EQ(0, results["found"]);@@ -1847,7 +1847,7 @@ TEST_F(CollectionTest, DeletionOfDocumentSingularFields) {Option<nlohmann::json> add_op = coll1->add(doc.dump());ASSERT_TRUE(add_op.ok());- nlohmann::json res = coll1->search("phone", {"str"}, "", {}, sort_fields, 0, 10, 1,+ nlohmann::json res = coll1->search("phone", {"str"}, "", {}, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10).get();@@ -1857,7 +1857,7 @@ TEST_F(CollectionTest, DeletionOfDocumentSingularFields) {ASSERT_TRUE(rem_op.ok());- res = coll1->search("phone", {"str"}, "", {}, sort_fields, 0, 10, 1,+ res = coll1->search("phone", {"str"}, "", {}, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10).get();@@ -1913,7 +1913,7 @@ TEST_F(CollectionTest, DeletionOfDocumentArrayFields) {Option<nlohmann::json> add_op = coll1->add(doc.dump());ASSERT_TRUE(add_op.ok());- nlohmann::json res = coll1->search("phone", {"strarray"}, "", {}, sort_fields, 0, 10, 1,+ nlohmann::json res = coll1->search("phone", {"strarray"}, "", {}, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10).get();@@ -1923,7 +1923,7 @@ TEST_F(CollectionTest, DeletionOfDocumentArrayFields) {ASSERT_TRUE(rem_op.ok());- res = coll1->search("phone", {"strarray"}, "", {}, sort_fields, 0, 10, 1,+ res = coll1->search("phone", {"strarray"}, "", {}, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10).get();@@ -1983,12 +1983,12 @@ TEST_F(CollectionTest, SearchLargeTextField) {infile.close();- Option<nlohmann::json> res_op = coll_large_text->search("eguilazer", {"text"}, "", {}, sort_fields, 0, 10);+ Option<nlohmann::json> res_op = coll_large_text->search("eguilazer", {"text"}, "", {}, sort_fields, {0}, 10);ASSERT_TRUE(res_op.ok());nlohmann::json results = res_op.get();ASSERT_EQ(1, results["hits"].size());- res_op = coll_large_text->search("tristique", {"text"}, "", {}, sort_fields, 0, 10);+ res_op = coll_large_text->search("tristique", {"text"}, "", {}, sort_fields, {0}, 10);ASSERT_TRUE(res_op.ok());results = res_op.get();ASSERT_EQ(2, results["hits"].size());@@ -1996,7 +1996,7 @@ TEST_F(CollectionTest, SearchLargeTextField) {// query whose length exceeds maximum highlight window (match score's WINDOW_SIZE)res_op = coll_large_text->search("Phasellus non tristique elit Praesent non arcu id lectus accumsan venenatis at",- {"text"}, "", {}, sort_fields, 0, 10+ {"text"}, "", {}, sort_fields, {0}, 10);ASSERT_TRUE(res_op.ok());@@ -2007,7 +2007,7 @@ TEST_F(CollectionTest, SearchLargeTextField) {// only single matched token in match window- res_op = coll_large_text->search("molestie maecenas accumsan", {"text"}, "", {}, sort_fields, 0, 10);+ res_op = coll_large_text->search("molestie maecenas accumsan", {"text"}, "", {}, sort_fields, {0}, 10);ASSERT_TRUE(res_op.ok());results = res_op.get();@@ -2102,7 +2102,7 @@ TEST_F(CollectionTest, SearchHighlightShouldFollowThreshold) {// first with a large threshold- auto res = coll1->search("lazy", {"title"}, "", {}, sort_fields, 0, 10, 1,+ auto res = coll1->search("lazy", {"title"}, "", {}, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "").get();@@ -2111,7 +2111,7 @@ TEST_F(CollectionTest, SearchHighlightShouldFollowThreshold) {// now with with a small threshold (will show only 4 words either side of the matched token)- res = coll1->search("lazy", {"title"}, "", {}, sort_fields, 0, 10, 1,+ res = coll1->search("lazy", {"title"}, "", {}, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 5).get();@@ -2121,14 +2121,14 @@ TEST_F(CollectionTest, SearchHighlightShouldFollowThreshold) {// specify the number of surrounding tokens to returnsize_t highlight_affix_num_tokens = 2;- res = coll1->search("lazy", {"title"}, "", {}, sort_fields, 0, 10, 1,+ res = coll1->search("lazy", {"title"}, "", {}, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 5, highlight_affix_num_tokens).get();ASSERT_STREQ("over the <mark>lazy</mark> dog and",res["hits"][0]["highlights"][0]["snippet"].get<std::string>().c_str());highlight_affix_num_tokens = 0;- res = coll1->search("lazy", {"title"}, "", {}, sort_fields, 0, 10, 1,+ res = coll1->search("lazy", {"title"}, "", {}, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 5, highlight_affix_num_tokens).get();ASSERT_STREQ("<mark>lazy</mark>",@@ -2160,7 +2160,7 @@ TEST_F(CollectionTest, SearchHighlightShouldUseHighlightTags) {// use non-default highlighting tags- auto res = coll1->search("lazy", {"title"}, "", {}, sort_fields, 0, 10, 1,+ auto res = coll1->search("lazy", {"title"}, "", {}, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 30, 4, "", 40, {}, {}, {}, 0,"<em class=\"h\">", "</em>").get();@@ -2192,7 +2192,7 @@ TEST_F(CollectionTest, SearchHighlightWithNewLine) {auto add_op = coll1->add(doc.dump());ASSERT_TRUE(add_op.ok());- auto res = coll1->search("stark", {"title"}, "", {}, sort_fields, 0, 10, 1,+ auto res = coll1->search("stark", {"title"}, "", {}, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 30, 4, "", 40, {}, {}, {}, 0).get();@@ -2227,7 +2227,7 @@ TEST_F(CollectionTest, UpdateDocument) {auto add_op = coll1->add(doc.dump());ASSERT_TRUE(add_op.ok());- auto res = coll1->search("lazy", {"title"}, "", {"tags"}, sort_fields, 0, 10, 1,+ auto res = coll1->search("lazy", {"title"}, "", {"tags"}, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 5, 5, "title").get();@@ -2239,7 +2239,7 @@ TEST_F(CollectionTest, UpdateDocument) {add_op = coll1->add(doc.dump(), UPSERT);ASSERT_TRUE(add_op.ok());- res = coll1->search("lazy", {"title"}, "", {"tags"}, sort_fields, 0, 10, 1,+ res = coll1->search("lazy", {"title"}, "", {"tags"}, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 5, 5, "title").get();@@ -2261,13 +2261,13 @@ TEST_F(CollectionTest, UpdateDocument) {ASSERT_EQ(1, coll1->get_num_documents());- res = coll1->search("lazy", {"title"}, "", {"tags"}, sort_fields, 0, 10, 1,+ res = coll1->search("lazy", {"title"}, "", {"tags"}, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 5, 5, "title").get();ASSERT_EQ(0, res["hits"].size());- res = coll1->search("quick", {"title"}, "", {"title"}, sort_fields, 0, 10, 1,+ res = coll1->search("quick", {"title"}, "", {"title"}, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 5, 5, "title").get();@@ -2287,14 +2287,14 @@ TEST_F(CollectionTest, UpdateDocument) {ASSERT_TRUE(add_op.ok());// check for old tag- res = coll1->search("NEWS", {"tags"}, "", {"tags"}, sort_fields, 0, 10, 1,+ res = coll1->search("NEWS", {"tags"}, "", {"tags"}, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 5, 5, "title").get();ASSERT_EQ(0, res["hits"].size());// now check for new tag and also try faceting on that field- res = coll1->search("SENTENCE", {"tags"}, "", {"tags"}, sort_fields, 0, 10, 1,+ res = coll1->search("SENTENCE", {"tags"}, "", {"tags"}, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 5, 5, "title").get();@@ -2309,7 +2309,7 @@ TEST_F(CollectionTest, UpdateDocument) {add_op = coll1->add(doc3.dump(), UPDATE);ASSERT_TRUE(add_op.ok());- res = coll1->search("*", {"tags"}, "points: > 90", {"tags"}, sort_fields, 0, 10, 1,+ res = coll1->search("*", {"tags"}, "points: > 90", {"tags"}, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 5, 5, "title").get();@@ -2323,7 +2323,7 @@ TEST_F(CollectionTest, UpdateDocument) {add_op = coll1->add(doc4.dump(), UPSERT, "100");ASSERT_TRUE(add_op.ok());- res = coll1->search("*", {"tags"}, "points: > 101", {"tags"}, sort_fields, 0, 10, 1,+ res = coll1->search("*", {"tags"}, "points: > 101", {"tags"}, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 5, 5, "title").get();@@ -2335,7 +2335,7 @@ TEST_F(CollectionTest, UpdateDocument) {add_op = coll1->add(doc4.dump(), UPSERT, "100");ASSERT_FALSE(add_op.ok());- res = coll1->search("*", {"tags"}, "points: > 101", {"tags"}, sort_fields, 0, 10, 1,+ res = coll1->search("*", {"tags"}, "points: > 101", {"tags"}, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 5, 5, "title").get();@@ -2398,7 +2398,7 @@ TEST_F(CollectionTest, UpdateDocumentSorting) {auto add_op = coll1->add(doc1.dump());coll1->add(doc2.dump());- auto res = coll1->search("*", {"tags"}, "", {"tags"}, sort_fields, 0, 10, 1,+ auto res = coll1->search("*", {"tags"}, "", {"tags"}, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 5, 5, "title").get();@@ -2413,7 +2413,7 @@ TEST_F(CollectionTest, UpdateDocumentSorting) {doc1["points"] = 1000;coll1->add(doc1.dump(), UPDATE);- res = coll1->search("*", {"tags"}, "", {"tags"}, sort_fields, 0, 10, 1,+ res = coll1->search("*", {"tags"}, "", {"tags"}, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 5, 5, "title").get();@@ -2452,7 +2452,7 @@ TEST_F(CollectionTest, SearchHighlightFieldFully) {// look for fully highlighted value in response- auto res = coll1->search("lazy", {"title"}, "", {}, sort_fields, 0, 10, 1,+ auto res = coll1->search("lazy", {"title"}, "", {}, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 5, 5, "title").get();@@ -2461,14 +2461,14 @@ TEST_F(CollectionTest, SearchHighlightFieldFully) {res["hits"][0]["highlights"][0]["value"].get<std::string>().c_str());// should not return value key when highlight_full_fields is not specified- res = coll1->search("lazy", {"title"}, "", {}, sort_fields, 0, 10, 1,+ res = coll1->search("lazy", {"title"}, "", {}, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 5, 5, "").get();ASSERT_EQ(3, res["hits"][0]["highlights"][0].size());// query multiple fields- res = coll1->search("lazy", {"title", "tags"}, "", {}, sort_fields, 0, 10, 1,+ res = coll1->search("lazy", {"title", "tags"}, "", {}, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 5, 5, "title, tags").get();@@ -2485,7 +2485,7 @@ TEST_F(CollectionTest, SearchHighlightFieldFully) {// excluded fields should not be returned in highlights sectionspp::sparse_hash_set<std::string> excluded_fields = {"tags"};- res = coll1->search("lazy", {"title", "tags"}, "", {}, sort_fields, 0, 10, 1,+ res = coll1->search("lazy", {"title", "tags"}, "", {}, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),excluded_fields, 10, "", 5, 5, "title, tags").get();@@ -2495,7 +2495,7 @@ TEST_F(CollectionTest, SearchHighlightFieldFully) {// when all fields are excludedexcluded_fields = {"tags", "title"};- res = coll1->search("lazy", {"title", "tags"}, "", {}, sort_fields, 0, 10, 1,+ res = coll1->search("lazy", {"title", "tags"}, "", {}, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),excluded_fields, 10, "", 5, 5, "title, tags").get();ASSERT_EQ(0, res["hits"][0]["highlights"].size());@@ -2536,26 +2536,26 @@ TEST_F(CollectionTest, OptionalFields) {// first must be able to fetch all records (i.e. all must have been indexed)- auto res = coll1->search("*", {"title"}, "", {}, {}, 0, 10, 1, FREQUENCY, false).get();+ auto res = coll1->search("*", {"title"}, "", {}, {}, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(6, res["found"].get<size_t>());// search on optional `description` field- res = coll1->search("book", {"description"}, "", {}, {}, 0, 10, 1, FREQUENCY, false).get();+ res = coll1->search("book", {"description"}, "", {}, {}, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(5, res["found"].get<size_t>());// filter on optional `average` field- res = coll1->search("the", {"title"}, "average: >0", {}, {}, 0, 10, 1, FREQUENCY, false).get();+ res = coll1->search("the", {"title"}, "average: >0", {}, {}, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(5, res["found"].get<size_t>());// facet on optional `description` field- res = coll1->search("the", {"title"}, "", {"description"}, {}, 0, 10, 1, FREQUENCY, false).get();+ res = coll1->search("the", {"title"}, "", {"description"}, {}, {0}, 10, 1, FREQUENCY, false).get();ASSERT_EQ(6, res["found"].get<size_t>());ASSERT_EQ(5, res["facet_counts"][0]["counts"][0]["count"].get<size_t>());ASSERT_STREQ("description", res["facet_counts"][0]["field_name"].get<std::string>().c_str());// sort_by optional `average` field should be allowed (default used for missing values)std::vector<sort_by> sort_fields = { sort_by("average", "DESC") };- auto res_op = coll1->search("*", {"title"}, "", {}, sort_fields, 0, 10, 1, FREQUENCY, false);+ auto res_op = coll1->search("*", {"title"}, "", {}, sort_fields, {0}, 10, 1, FREQUENCY, false);ASSERT_TRUE(res_op.ok());res = res_op.get();@@ -2624,7 +2624,7 @@ TEST_F(CollectionTest, OptionalFieldCanBeNull) {ASSERT_EQ(0, coll1->_get_indexes()[0]->_get_search_index().at("genres")->size);auto results = coll1->search("beat",- {"title", "artist"}, "", {}, {}, 0, 10, 1, FREQUENCY).get();+ {"title", "artist"}, "", {}, {}, {0}, 10, 1, FREQUENCY).get();ASSERT_EQ(1, results["found"].get<size_t>());ASSERT_EQ(1, results["hits"].size());@@ -2660,7 +2660,7 @@ TEST_F(CollectionTest, EmptyStringNotIndexed) {ASSERT_TRUE(coll1->add(doc.dump()).ok());auto results = coll1->search("beat",- {"title", "artist"}, "", {}, {}, 0, 10, 1, FREQUENCY).get();+ {"title", "artist"}, "", {}, {}, {0}, 10, 1, FREQUENCY).get();ASSERT_EQ(1, results["found"].get<size_t>());ASSERT_EQ(1, results["hits"].size());@@ -2677,28 +2677,28 @@ TEST_F(CollectionTest, EmptyStringNotIndexed) {TEST_F(CollectionTest, WildcardQueryReturnsResultsBasedOnPerPageParam) {std::vector<std::string> facets;spp::sparse_hash_set<std::string> empty;- nlohmann::json results = collection->search("*", query_fields, "", facets, sort_fields, 0, 12, 1,+ nlohmann::json results = collection->search("*", query_fields, "", facets, sort_fields, {0}, 12, 1,FREQUENCY, false, 1000, empty, empty, 10).get();ASSERT_EQ(12, results["hits"].size());ASSERT_EQ(25, results["found"].get<int>());// should match collection size- results = collection->search("*", query_fields, "", facets, sort_fields, 0, 100, 1,+ results = collection->search("*", query_fields, "", facets, sort_fields, {0}, 100, 1,FREQUENCY, false, 1000, empty, empty, 10).get();ASSERT_EQ(25, results["hits"].size());ASSERT_EQ(25, results["found"].get<int>());// cannot fetch more than in-built limit of 250- auto res_op = collection->search("*", query_fields, "", facets, sort_fields, 0, 251, 1,+ auto res_op = collection->search("*", query_fields, "", facets, sort_fields, {0}, 251, 1,FREQUENCY, false, 1000, empty, empty, 10);ASSERT_FALSE(res_op.ok());ASSERT_EQ(422, res_op.code());ASSERT_STREQ("Only upto 250 hits can be fetched per page.", res_op.error().c_str());// when page number is not valid- res_op = collection->search("*", query_fields, "", facets, sort_fields, 0, 10, 0,+ res_op = collection->search("*", query_fields, "", facets, sort_fields, {0}, 10, 0,FREQUENCY, false, 1000, empty, empty, 10);ASSERT_FALSE(res_op.ok());ASSERT_EQ(422, res_op.code());@@ -2706,26 +2706,26 @@ TEST_F(CollectionTest, WildcardQueryReturnsResultsBasedOnPerPageParam) {// do pagination- results = collection->search("*", query_fields, "", facets, sort_fields, 0, 10, 1,+ results = collection->search("*", query_fields, "", facets, sort_fields, {0}, 10, 1,FREQUENCY, false, 1000, empty, empty, 10).get();ASSERT_EQ(10, results["hits"].size());ASSERT_EQ(25, results["found"].get<int>());- results = collection->search("*", query_fields, "", facets, sort_fields, 0, 10, 2,+ results = collection->search("*", query_fields, "", facets, sort_fields, {0}, 10, 2,FREQUENCY, false, 1000, empty, empty, 10).get();ASSERT_EQ(10, results["hits"].size());ASSERT_EQ(25, results["found"].get<int>());- results = collection->search("*", query_fields, "", facets, sort_fields, 0, 10, 3,+ results = collection->search("*", query_fields, "", facets, sort_fields, {0}, 10, 3,FREQUENCY, false, 1000, empty, empty, 10).get();ASSERT_EQ(5, results["hits"].size());ASSERT_EQ(25, results["found"].get<int>());// enforce limit_hits- res_op = collection->search("*", query_fields, "", facets, sort_fields, 0, 10, 3,+ res_op = collection->search("*", query_fields, "", facets, sort_fields, {0}, 10, 3,FREQUENCY, false, 1000,spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 30, 4, "", 40, {}, {}, {}, 0,@@ -2760,7 +2760,7 @@ TEST_F(CollectionTest, RemoveIfFound) {coll1->add(doc.dump());}- auto res = coll1->search("*", {"title"}, "", {}, sort_fields, 0, 10, 1,+ auto res = coll1->search("*", {"title"}, "", {}, sort_fields, {0}, 10, 1,token_ordering::FREQUENCY, true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 30, 4, "", 40, {}, {}, {}, 0).get();@@ -2830,7 +2830,7 @@ TEST_F(CollectionTest, MultiFieldRelevance) {}auto results = coll1->search("Dustin Kensrue Down There by the Train",- {"title", "artist"}, "", {}, {}, 0, 10, 1, FREQUENCY).get();+ {"title", "artist"}, "", {}, {}, {0}, 10, 1, FREQUENCY).get();ASSERT_EQ(3, results["found"].get<size_t>());ASSERT_EQ(3, results["hits"].size());@@ -2873,7 +2873,7 @@ TEST_F(CollectionTest, MultiFieldRelevance) {}results = coll1->search("Dustin Kensrue Down There by the Train",- {"title", "artist"}, "", {}, {}, 0, 10, 1, FREQUENCY).get();+ {"title", "artist"}, "", {}, {}, {0}, 10, 1, FREQUENCY).get();ASSERT_EQ(3, results["found"].get<size_t>());ASSERT_EQ(3, results["hits"].size());@@ -2886,7 +2886,7 @@ TEST_F(CollectionTest, MultiFieldRelevance) {// with exclude token syntaxresults = coll1->search("-downie dustin kensrue down there by the train",- {"title", "artist"}, "", {}, {}, 0, 10, 1, FREQUENCY).get();+ {"title", "artist"}, "", {}, {}, {0}, 10, 1, FREQUENCY).get();ASSERT_EQ(2, results["found"].get<size_t>());ASSERT_EQ(2, results["hits"].size());@@ -2929,7 +2929,7 @@ TEST_F(CollectionTest, MultiFieldRelevance2) {}auto results = coll1->search("on a jetplane",- {"title", "artist"}, "", {}, {}, 0, 10, 1, FREQUENCY).get();+ {"title", "artist"}, "", {}, {}, {0}, 10, 1, FREQUENCY).get();ASSERT_EQ(2, results["found"].get<size_t>());ASSERT_EQ(2, results["hits"].size());@@ -2940,7 +2940,7 @@ TEST_F(CollectionTest, MultiFieldRelevance2) {// change weights to favor artistresults = coll1->search("on a jetplane",- {"title", "artist"}, "", {}, {}, 0, 10, 1, FREQUENCY,+ {"title", "artist"}, "", {}, {}, {0}, 10, 1, FREQUENCY,true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 30, 4, "", 40, {}, {}, {}, 0,"<mark>", "</mark>", {1, 4}).get();@@ -2965,7 +2965,7 @@ TEST_F(CollectionTest, FieldWeightsNotProper) {}auto results_op = coll1->search("on a jetplane",- {"title", "artist"}, "", {}, {}, 0, 10, 1, FREQUENCY,+ {"title", "artist"}, "", {}, {}, {0}, 10, 1, FREQUENCY,true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 30, 4, "", 40, {}, {}, {}, 0,"<mark>", "</mark>", {1});@@ -2975,7 +2975,7 @@ TEST_F(CollectionTest, FieldWeightsNotProper) {"of `query_by` fields.", results_op.error().c_str());results_op = coll1->search("on a jetplane",- {"title"}, "", {}, {}, 0, 10, 1, FREQUENCY,+ {"title"}, "", {}, {}, {0}, 10, 1, FREQUENCY,true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 30, 4, "", 40, {}, {}, {}, 0,"<mark>", "</mark>", {2, 1});@@ -2987,7 +2987,7 @@ TEST_F(CollectionTest, FieldWeightsNotProper) {// empty weights are fine (will be defaulted to)results_op = coll1->search("on a jetplane",- {"title"}, "", {}, {}, 0, 10, 1, FREQUENCY,+ {"title"}, "", {}, {}, {0}, 10, 1, FREQUENCY,true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 30, 4, "", 40, {}, {}, {}, 0,"<mark>", "</mark>", {});@@ -3026,7 +3026,7 @@ TEST_F(CollectionTest, MultiFieldRelevance3) {}auto results = coll1->search("style taylor swift",- {"title", "artist"}, "", {}, {}, 0, 10, 1, FREQUENCY,+ {"title", "artist"}, "", {}, {}, {0}, 10, 1, FREQUENCY,true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 30, 4, "", 40, {}, {}, {}, 0,"<mark>", "</mark>", {1, 1}).get();@@ -3038,7 +3038,7 @@ TEST_F(CollectionTest, MultiFieldRelevance3) {ASSERT_STREQ("0", results["hits"][1]["document"]["id"].get<std::string>().c_str());results = coll1->search("swift",- {"title", "artist"}, "", {}, {}, 0, 10, 1, FREQUENCY,+ {"title", "artist"}, "", {}, {}, {0}, 10, 1, FREQUENCY,true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 30, 4, "", 40, {}, {}, {}, 0,"<mark>", "</mark>", {1, 1}).get();@@ -3081,7 +3081,7 @@ TEST_F(CollectionTest, MultiFieldRelevance4) {}auto results = coll1->search("madras",- {"title", "artist"}, "", {}, {}, 2, 10, 1, FREQUENCY,+ {"title", "artist"}, "", {}, {}, {2}, 10, 1, FREQUENCY,true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 30, 4, "", 40, {}, {}, {}, 0,"<mark>", "</mark>", {1, 1}).get();@@ -3127,7 +3127,7 @@ TEST_F(CollectionTest, MultiFieldRelevance5) {}auto results = coll1->search("Canada",- {"company_name","country","field_a"}, "", {}, {}, 2, 10, 1, FREQUENCY,+ {"company_name","country","field_a"}, "", {}, {}, {2}, 10, 1, FREQUENCY,true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 30, 4, "", 40, {}, {}, {}, 0,"<mark>", "</mark>", {1, 1, 1}).get();@@ -3136,11 +3136,11 @@ TEST_F(CollectionTest, MultiFieldRelevance5) {ASSERT_EQ(3, results["hits"].size());ASSERT_STREQ("0", results["hits"][0]["document"]["id"].get<std::string>().c_str());- ASSERT_STREQ("2", results["hits"][1]["document"]["id"].get<std::string>().c_str());- ASSERT_STREQ("1", results["hits"][2]["document"]["id"].get<std::string>().c_str());+ ASSERT_STREQ("1", results["hits"][1]["document"]["id"].get<std::string>().c_str());+ ASSERT_STREQ("2", results["hits"][2]["document"]["id"].get<std::string>().c_str());results = coll1->search("Canada",- {"company_name","field_a","country"}, "", {}, {}, 2, 10, 1, FREQUENCY,+ {"company_name","field_a","country"}, "", {}, {}, {2}, 10, 1, FREQUENCY,true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 30, 4, "", 40, {}, {}, {}, 0,"<mark>", "</mark>", {1, 1, 1}).get();@@ -3149,20 +3149,20 @@ TEST_F(CollectionTest, MultiFieldRelevance5) {ASSERT_EQ(3, results["hits"].size());ASSERT_STREQ("0", results["hits"][0]["document"]["id"].get<std::string>().c_str());- ASSERT_STREQ("2", results["hits"][1]["document"]["id"].get<std::string>().c_str());- ASSERT_STREQ("1", results["hits"][2]["document"]["id"].get<std::string>().c_str());+ ASSERT_STREQ("1", results["hits"][1]["document"]["id"].get<std::string>().c_str());+ ASSERT_STREQ("2", results["hits"][2]["document"]["id"].get<std::string>().c_str());ASSERT_EQ(1, results["hits"][0]["highlights"].size());ASSERT_EQ("country", results["hits"][0]["highlights"][0]["field"].get<std::string>());ASSERT_EQ("<mark>Canada</mark>", results["hits"][0]["highlights"][0]["snippet"].get<std::string>());ASSERT_EQ(1, results["hits"][1]["highlights"].size());- ASSERT_EQ("field_a", results["hits"][1]["highlights"][0]["field"].get<std::string>());- ASSERT_EQ("<mark>Canadoo</mark>", results["hits"][1]["highlights"][0]["snippet"].get<std::string>());+ ASSERT_EQ("company_name", results["hits"][1]["highlights"][0]["field"].get<std::string>());+ ASSERT_EQ("<mark>Canaida</mark> Corp", results["hits"][1]["highlights"][0]["snippet"].get<std::string>());ASSERT_EQ(1, results["hits"][2]["highlights"].size());- ASSERT_EQ("company_name", results["hits"][2]["highlights"][0]["field"].get<std::string>());- ASSERT_EQ("<mark>Canaida</mark> Corp", results["hits"][2]["highlights"][0]["snippet"].get<std::string>());+ ASSERT_EQ("field_a", results["hits"][2]["highlights"][0]["field"].get<std::string>());+ ASSERT_EQ("<mark>Canadoo</mark>", results["hits"][2]["highlights"][0]["snippet"].get<std::string>());collectionManager.drop_collection("coll1");}@@ -3197,7 +3197,7 @@ TEST_F(CollectionTest, MultiFieldRelevance6) {}auto results = coll1->search("taylor swift",- {"title", "artist"}, "", {}, {}, 2, 10, 1, FREQUENCY,+ {"title", "artist"}, "", {}, {}, {2}, 10, 1, FREQUENCY,true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 30, 4, "", 40, {}, {}, {}, 0,"<mark>", "</mark>", {1, 1}).get();@@ -3210,7 +3210,7 @@ TEST_F(CollectionTest, MultiFieldRelevance6) {// when exact matches are disabledresults = coll1->search("taylor swift",- {"title", "artist"}, "", {}, {}, 2, 10, 1, FREQUENCY,+ {"title", "artist"}, "", {}, {}, {2}, 10, 1, FREQUENCY,true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 30, 4, "", 40, {}, {}, {}, 0,"<mark>", "</mark>", {1, 1}, 100, false).get();@@ -3254,7 +3254,7 @@ TEST_F(CollectionTest, ExactMatch) {}auto results = coll1->search("alpha beta",- {"title"}, "", {}, {}, 2, 10, 1, FREQUENCY,+ {"title"}, "", {}, {}, {2}, 10, 1, FREQUENCY,true, 10).get();ASSERT_EQ(2, results["found"].get<size_t>());@@ -3263,7 +3263,7 @@ TEST_F(CollectionTest, ExactMatch) {ASSERT_STREQ("1", results["hits"][0]["document"]["id"].get<std::string>().c_str());ASSERT_STREQ("2", results["hits"][1]["document"]["id"].get<std::string>().c_str());- results = coll1->search("alpha", {"title"}, "", {}, {}, 2, 10, 1, FREQUENCY, true, 10).get();+ results = coll1->search("alpha", {"title"}, "", {}, {}, {2}, 10, 1, FREQUENCY, true, 10).get();ASSERT_EQ(3, results["found"].get<size_t>());ASSERT_EQ(3, results["hits"].size());@@ -3313,7 +3313,7 @@ TEST_F(CollectionTest, MultiFieldHighlighting) {}auto results = coll1->search("charger",- {"name","description","categories"}, "", {}, {}, 2, 10, 1, FREQUENCY,+ {"name","description","categories"}, "", {}, {}, {2}, 10, 1, FREQUENCY,true, 10, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 30, 4, "", 40, {}, {}, {}, 0,"<mark>", "</mark>", {1, 1, 1}).get();@@ -3333,7 +3333,7 @@ TEST_F(CollectionTest, MultiFieldHighlighting) {results["hits"][0]["highlights"][1]["snippet"].get<std::string>());results = coll1->search("John With Denver",- {"description"}, "", {}, {}, 0, 10, 1, FREQUENCY,+ {"description"}, "", {}, {}, {0}, 10, 1, FREQUENCY,true, 1, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 30, 4, "", 40, {}, {}, {}, 0,"<mark>", "</mark>", {1}).get();@@ -3348,7 +3348,7 @@ TEST_F(CollectionTest, MultiFieldHighlighting) {results["hits"][0]["highlights"][0]["snippet"].get<std::string>());results = coll1->search("Annies song John Denver",- {"name","description"}, "", {}, {}, 0, 10, 1, FREQUENCY,+ {"name","description"}, "", {}, {}, {0}, 10, 1, FREQUENCY,true, 1, spp::sparse_hash_set<std::string>(),spp::sparse_hash_set<std::string>(), 10, "", 30, 4, "", 40, {}, {}, {}, 0,"<mark>", "</mark>", {1, 1}).get();@@ -3407,7 +3407,7 @@ TEST_F(CollectionTest, MultiFieldMatchRanking) {}auto results = coll1->search("taylor swift style",- {"artist", "title"}, "", {}, {}, 0, 3, 1, FREQUENCY, true, 5).get();+ {"artist", "title"}, "", {}, {}, {0}, 3, 1, FREQUENCY, true, 5).get();ASSERT_EQ(10, results["found"].get<size_t>());ASSERT_EQ(3, results["hits"].size());@@ -3450,7 +3450,7 @@ TEST_F(CollectionTest, MultiFieldMatchRankingOnArray) {}auto results = coll1->search("golang vue",- {"strong_skills", "skills"}, "", {}, {}, 0, 3, 1, FREQUENCY, true, 5).get();+ {"strong_skills", "skills"}, "", {}, {}, {0}, 3, 1, FREQUENCY, true, 5).get();ASSERT_EQ(2, results["found"].get<size_t>());ASSERT_EQ(2, results["hits"].size());@@ -3490,7 +3490,7 @@ TEST_F(CollectionTest, MultiFieldMatchRankingOnFieldOrder) {}auto results = coll1->search("michael jackson toxic",- {"title", "artist"}, "", {}, {}, 0, 3, 1, FREQUENCY, true, 5).get();+ {"title", "artist"}, "", {}, {}, {0}, 3, 1, FREQUENCY, true, 5).get();ASSERT_EQ(2, results["found"].get<size_t>());ASSERT_EQ(2, results["hits"].size());@@ -3529,7 +3529,7 @@ TEST_F(CollectionTest, PrefixRankedAfterExactMatch) {ASSERT_TRUE(coll1->add(doc.dump()).ok());}- auto results = coll1->search("roti", {"title"}, "", {}, {}, 0, 3, 1, FREQUENCY, true, 5).get();+ auto results = coll1->search("roti", {"title"}, "", {}, {}, {0}, 3, 1, FREQUENCY, true, 5).get();ASSERT_EQ(4, results["found"].get<size_t>());ASSERT_EQ(3, results["hits"].size());@@ -3569,7 +3569,7 @@ TEST_F(CollectionTest, HighlightWithAccentedCharacters) {ASSERT_TRUE(coll1->add(doc.dump()).ok());}- auto results = coll1->search("à jour", {"title"}, "", {}, {}, 0, 10, 1, FREQUENCY).get();+ auto results = coll1->search("à jour", {"title"}, "", {}, {}, {0}, 10, 1, FREQUENCY).get();ASSERT_EQ(1, results["found"].get<size_t>());ASSERT_EQ(1, results["hits"].size());@@ -3581,7 +3581,7 @@ TEST_F(CollectionTest, HighlightWithAccentedCharacters) {ASSERT_STREQ("à", results["hits"][0]["highlights"][0]["matched_tokens"][0].get<std::string>().c_str());ASSERT_STREQ("jour", results["hits"][0]["highlights"][0]["matched_tokens"][1].get<std::string>().c_str());- results = coll1->search("by train", {"title"}, "", {}, {}, 0, 10, 1, FREQUENCY).get();+ results = coll1->search("by train", {"title"}, "", {}, {}, {0}, 10, 1, FREQUENCY).get();ASSERT_EQ(1, results["found"].get<size_t>());ASSERT_EQ(1, results["hits"].size());@@ -3589,7 +3589,7 @@ TEST_F(CollectionTest, HighlightWithAccentedCharacters) {ASSERT_STREQ("Down There <mark>by</mark> the <mark>T.r.a.i.n</mark>",results["hits"][0]["highlights"][0]["snippet"].get<std::string>().c_str());- results = coll1->search("state trooper", {"title"}, "", {}, {}, 0, 10, 1, FREQUENCY).get();+ results = coll1->search("state trooper", {"title"}, "", {}, {}, {0}, 10, 1, FREQUENCY).get();ASSERT_EQ(1, results["found"].get<size_t>());ASSERT_EQ(1, results["hits"].size());@@ -3599,7 +3599,7 @@ TEST_F(CollectionTest, HighlightWithAccentedCharacters) {// test single character highlight- results = coll1->search("q", {"title"}, "", {}, {}, 0, 10, 1, FREQUENCY).get();+ results = coll1->search("q", {"title"}, "", {}, {}, {0}, 10, 1, FREQUENCY).get();ASSERT_EQ(1, results["found"].get<size_t>());ASSERT_STREQ("The Google Nexus <mark>Q</mark> Is Baffling",results["hits"][0]["highlights"][0]["snippet"].get<std::string>().c_str());@@ -3638,7 +3638,7 @@ TEST_F(CollectionTest, DISABLED_SearchingForRecordsWithSpecialChars) {}auto results = coll1->search("google",- {"title", "url"}, "", {}, {}, 2, 10, 1, FREQUENCY).get();+ {"title", "url"}, "", {}, {}, {2}, 10, 1, FREQUENCY).get();ASSERT_EQ(1, results["found"].get<size_t>());ASSERT_STREQ("1", results["hits"][0]["document"]["id"].get<std::string>().c_str());@@ -3648,7 +3648,7 @@ TEST_F(CollectionTest, DISABLED_SearchingForRecordsWithSpecialChars) {ASSERT_EQ("https://<mark>google</mark>.com///", results["hits"][0]["highlights"][1]["snippet"].get<std::string>());results = coll1->search("amazon.com",- {"title", "url"}, "", {}, {}, 2, 10, 1, FREQUENCY).get();+ {"title", "url"}, "", {}, {}, {2}, 10, 1, FREQUENCY).get();ASSERT_EQ(3, results["found"].get<size_t>());ASSERT_STREQ("3", results["hits"][0]["document"]["id"].get<std::string>().c_str());@@ -3656,13 +3656,13 @@ TEST_F(CollectionTest, DISABLED_SearchingForRecordsWithSpecialChars) {ASSERT_STREQ("1", results["hits"][2]["document"]["id"].get<std::string>().c_str());results = coll1->search("typesense",- {"title", "url"}, "", {}, {}, 2, 10, 1, FREQUENCY).get();+ {"title", "url"}, "", {}, {}, {2}, 10, 1, FREQUENCY).get();ASSERT_EQ(1, results["found"].get<size_t>());ASSERT_STREQ("2", results["hits"][0]["document"]["id"].get<std::string>().c_str());results = coll1->search("nb_sb_noss_2",- {"title", "url"}, "", {}, {}, 2, 10, 1, FREQUENCY).get();+ {"title", "url"}, "", {}, {}, {2}, 10, 1, FREQUENCY).get();ASSERT_EQ(1, results["found"].get<size_t>());ASSERT_STREQ("3", results["hits"][0]["document"]["id"].get<std::string>().c_str());@@ -3673,3 +3673,88 @@ TEST_F(CollectionTest, DISABLED_SearchingForRecordsWithSpecialChars) {collectionManager.drop_collection("coll1");}++TEST_F(CollectionTest, FieldSpecificNumTypos) {+ Collection *coll1;++ std::vector<field> fields = {field("title", field_types::STRING, false),+ field("artist", field_types::STRING, false),+ field("points", field_types::INT32, false),};++ coll1 = collectionManager.get_collection("coll1").get();+ if(coll1 == nullptr) {+ coll1 = collectionManager.create_collection("coll1", 1, fields, "points").get();+ }++ std::vector<std::vector<std::string>> records = {+ {"Taylor Swift Karaoke: reputation", "Taylor Swift"},+ {"Taylor & Friends", "Adam Smith"},+ };++ for(size_t i=0; i<records.size(); i++) {+ nlohmann::json doc;++ doc["id"] = std::to_string(i);+ doc["title"] = records[i][0];+ doc["artist"] = records[i][1];+ doc["points"] = i;++ ASSERT_TRUE(coll1->add(doc.dump()).ok());+ }++ auto results = coll1->search("tayylor",+ {"title", "artist"}, "", {}, {}, {1, 1}, 10, 1, FREQUENCY,+ true, 10, spp::sparse_hash_set<std::string>(),+ spp::sparse_hash_set<std::string>(), 10, "", 30, 4, "", 40, {}, {}, {}, 0,+ "<mark>", "</mark>", {1, 1}).get();++ ASSERT_EQ(2, results["found"].get<size_t>());+ ASSERT_EQ(2, results["hits"].size());++ ASSERT_STREQ("0", results["hits"][0]["document"]["id"].get<std::string>().c_str());+ ASSERT_STREQ("1", results["hits"][1]["document"]["id"].get<std::string>().c_str());+++ results = coll1->search("tayylor",+ {"title", "artist"}, "", {}, {}, {0, 1}, 10, 1, FREQUENCY,+ true, 10, spp::sparse_hash_set<std::string>(),+ spp::sparse_hash_set<std::string>(), 10, "", 30, 4, "", 40, {}, {}, {}, 0,+ "<mark>", "</mark>", {1, 1}).get();++ ASSERT_EQ(1, results["found"].get<size_t>());+ ASSERT_EQ(1, results["hits"].size());++ ASSERT_STREQ("0", results["hits"][0]["document"]["id"].get<std::string>().c_str());++ // must return error when num_typos does not match length of search fields queried+ auto res_op = coll1->search("tayylor",+ {"title"}, "", {}, {}, {0, 1}, 10, 1, FREQUENCY,+ true, 10, spp::sparse_hash_set<std::string>(),+ spp::sparse_hash_set<std::string>(), 10, "", 30, 4, "", 40, {}, {}, {}, 0,+ "<mark>", "</mark>", {1, 1});++ ASSERT_FALSE(res_op.ok());+ ASSERT_EQ("Number of weights in `query_by_weights` does not match number of `query_by` fields.", res_op.error());++ // can use a single typo param for multiple fields+ results = coll1->search("tayylor",+ {"title", "artist"}, "", {}, {}, {1}, 10, 1, FREQUENCY,+ true, 10, spp::sparse_hash_set<std::string>(),+ spp::sparse_hash_set<std::string>(), 10, "", 30, 4, "", 40, {}, {}, {}, 0,+ "<mark>", "</mark>", {1, 1}).get();++ ASSERT_EQ(2, results["found"].get<size_t>());+ ASSERT_EQ(2, results["hits"].size());++ // wildcard search with typos+ results = coll1->search("*",+ {}, "", {}, {}, {1}, 10, 1, FREQUENCY,+ true, 10, spp::sparse_hash_set<std::string>(),+ spp::sparse_hash_set<std::string>(), 10, "", 30, 4, "", 40, {}, {}, {}, 0,+ "<mark>", "</mark>", {1, 1}).get();++ ASSERT_EQ(2, results["found"].get<size_t>());+ ASSERT_EQ(2, results["hits"].size());++ collectionManager.drop_collection("coll1");+}