mirror of
https://github.com/typesense/typesense.git
synced 2025-05-21 14:12:27 +08:00
Limit query tokens to 100 bytes.
This commit is contained in:
parent
16c681223c
commit
9e505a5322
@ -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);
|
||||
|
@ -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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user