Return token separators and symbols to index in API.

This commit is contained in:
Kishore Nallan 2021-10-12 16:10:37 +05:30
parent b17d5ab6df
commit 26fbad2c66
2 changed files with 26 additions and 0 deletions

View File

@ -148,6 +148,16 @@ nlohmann::json Collection::get_summary_json() const {
json_response["name"] = name;
json_response["num_documents"] = num_documents.load();
json_response["created_at"] = created_at.load();
json_response["token_separators"] = nlohmann::json::array();
json_response["symbols_to_index"] = nlohmann::json::array();
for(auto c: symbols_to_index) {
json_response["symbols_to_index"].push_back(std::string(1, c));
}
for(auto c: token_separators) {
json_response["token_separators"].push_back(std::string(1, c));
}
nlohmann::json fields_arr;

View File

@ -1032,6 +1032,12 @@ TEST_F(CollectionSpecificTest, CustomSymbolsForIndexing) {
"coll1", 1, fields, "points", 0, "", {"+"}, {}
).get();
nlohmann::json coll_summary = coll1->get_summary_json();
ASSERT_EQ(1, coll_summary["symbols_to_index"].size());
ASSERT_EQ(0, coll_summary["token_separators"].size());
ASSERT_EQ("+", coll_summary["symbols_to_index"][0].get<std::string>());
nlohmann::json doc1;
doc1["id"] = "0";
doc1["name"] = "Yes, C++ is great!";
@ -1115,6 +1121,16 @@ TEST_F(CollectionSpecificTest, CustomSeparatorsHandleQueryVariations) {
"coll1", 1, fields, "points", 0, "", {}, {"-", ".", "*", "&", "/"}
).get();
nlohmann::json coll_summary = coll1->get_summary_json();
ASSERT_EQ(0, coll_summary["symbols_to_index"].size());
ASSERT_EQ(5, coll_summary["token_separators"].size());
ASSERT_EQ("-", coll_summary["token_separators"][0].get<std::string>());
ASSERT_EQ(".", coll_summary["token_separators"][1].get<std::string>());
ASSERT_EQ("*", coll_summary["token_separators"][2].get<std::string>());
ASSERT_EQ("&", coll_summary["token_separators"][3].get<std::string>());
ASSERT_EQ("/", coll_summary["token_separators"][4].get<std::string>());
nlohmann::json doc1;
doc1["id"] = "0";
doc1["name"] = "1&1 Internet Limited";