Enabling exhaustive search should automatically drop tokens.

This commit is contained in:
Kishore Nallan 2023-02-02 16:48:18 +05:30
parent 344ab3b4e5
commit d44afc3295
2 changed files with 29 additions and 1 deletions

View File

@ -2782,7 +2782,7 @@ void Index::search(std::vector<query_tokens_t>& field_query_tokens, const std::v
// gather up both original query and synonym queries and do drop tokens
if (all_result_ids_len < drop_tokens_threshold) {
if (exhaustive_search || all_result_ids_len < drop_tokens_threshold) {
for (size_t qi = 0; qi < all_queries.size(); qi++) {
auto& orig_tokens = all_queries[qi];
size_t num_tokens_dropped = 0;

View File

@ -1869,6 +1869,34 @@ TEST_F(CollectionSpecificMoreTest, SearchCutoffTest) {
ASSERT_EQ(408, coll_op.code());
}
TEST_F(CollectionSpecificMoreTest, ExhaustiveSearchWithoutExplicitDropTokens) {
nlohmann::json schema = R"({
"name": "coll1",
"fields": [
{"name": "title", "type": "string"}
]
})"_json;
Collection* coll1 = collectionManager.create_collection(schema).get();
nlohmann::json doc;
doc["title"] = "alpha beta gamma";
ASSERT_TRUE(coll1->add(doc.dump()).ok());
doc["title"] = "alpha";
ASSERT_TRUE(coll1->add(doc.dump()).ok());
bool exhaustive_search = true;
size_t drop_tokens_threshold = 1;
auto res = coll1->search("alpha beta", {"title"}, "", {}, {}, {0}, 3, 1, FREQUENCY, {false}, drop_tokens_threshold,
spp::sparse_hash_set<std::string>(),
spp::sparse_hash_set<std::string>(), 10, "", 30, 4, "title", 20, {}, {}, {}, 0,
"<mark>", "</mark>", {}, 1000, true, false, true, "", exhaustive_search).get();
ASSERT_EQ(2, res["hits"].size());
}
TEST_F(CollectionSpecificMoreTest, CrossFieldTypoAndPrefixWithWeights) {
nlohmann::json schema = R"({
"name": "coll1",