Limit query tokens to 100 bytes.

This commit is contained in:
Kishore Nallan 2023-05-30 07:54:34 +05:30
parent 16c681223c
commit 9e505a5322
2 changed files with 27 additions and 0 deletions

View File

@ -2436,6 +2436,10 @@ void Collection::parse_search_query(const std::string &query, std::vector<std::s
}
for(auto& sub_token: sub_tokens) {
if(sub_token.size() > 100) {
sub_token.erase(100);
}
if(exclude_operator_prior) {
if(phrase_search_op_prior) {
phrase.push_back(sub_token);

View File

@ -2058,6 +2058,29 @@ TEST_F(CollectionSpecificMoreTest, DoNotHighlightFieldsForSpecialCharacterQuery)
ASSERT_EQ(0, res["hits"][0]["highlights"].size());
}
TEST_F(CollectionSpecificMoreTest, SearchForURL) {
nlohmann::json schema = R"({
"name": "coll1",
"fields": [
{"name": "url", "type": "string"}
]
})"_json;
Collection* coll1 = collectionManager.create_collection(schema).get();
nlohmann::json doc;
doc["url"] = "https://www.cpf.gov.sg/member/infohub/cpf-clarifies/policy-faqs/"
"why-interest-earned-on-cpf-life-premium-not-paid-to-beneficiaries";
ASSERT_TRUE(coll1->add(doc.dump()).ok());
auto res = coll1->search("https://www.cpf.gov.sg/member/infohub/cpf-clarifies/policy-faqs/"
"why-interest-earned-on-cpf-life-premium-not-paid-to-beneficiaries", {"url"}, "",
{}, {}, {2}, 3, 1,
FREQUENCY, {true}).get();
ASSERT_EQ(1, res["hits"].size());
}
TEST_F(CollectionSpecificMoreTest, CrossFieldTypoAndPrefixWithWeights) {
nlohmann::json schema = R"({
"name": "coll1",