mirror of
https://github.com/typesense/typesense.git
synced 2025-05-18 20:52:50 +08:00
Return token separators and symbols to index in API.
This commit is contained in:
parent
b17d5ab6df
commit
26fbad2c66
@ -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;
|
||||
|
||||
|
@ -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";
|
||||
|
Loading…
x
Reference in New Issue
Block a user