mirror of
https://github.com/typesense/typesense.git
synced 2025-05-19 13:12:22 +08:00
handle facet query with multiple tokens in value index
This commit is contained in:
parent
34b5aa7d61
commit
eeb7521394
@ -133,7 +133,7 @@ public:
|
||||
size_t get_facet_count(const std::string& field_name);
|
||||
|
||||
size_t intersect(facet& a_facet,
|
||||
bool has_facet_query, const std::vector<std::string>& fvalue_searched_tokens,
|
||||
bool has_facet_query, const std::vector<std::vector<std::string>>& fvalue_searched_tokens,
|
||||
const uint32_t* result_ids, size_t result_id_len,
|
||||
size_t max_facet_count, std::map<std::string, docid_count_t>& found,
|
||||
bool is_wildcard_no_filter_query, const std::string& sort_order = "");
|
||||
|
@ -677,7 +677,7 @@ struct facet {
|
||||
struct facet_info_t {
|
||||
// facet hash => resolved tokens
|
||||
std::unordered_map<uint64_t, std::vector<std::string>> hashes;
|
||||
std::vector<std::string> fvalue_searched_tokens;
|
||||
std::vector<std::vector<std::string>> fvalue_searched_tokens;
|
||||
bool use_facet_query = false;
|
||||
bool should_compute_stats = false;
|
||||
bool use_value_index = false;
|
||||
|
@ -158,7 +158,7 @@ size_t facet_index_t::get_facet_count(const std::string& field_name) {
|
||||
|
||||
//returns the count of matching seq_ids from result array
|
||||
size_t facet_index_t::intersect(facet& a_facet,
|
||||
bool has_facet_query, const std::vector<std::string>& fvalue_searched_tokens,
|
||||
bool has_facet_query, const std::vector<std::vector<std::string>>& fvalue_searched_tokens,
|
||||
const uint32_t* result_ids, size_t result_ids_len,
|
||||
size_t max_facet_count, std::map<std::string, docid_count_t>& found,
|
||||
bool is_wildcard_no_filter_query, const std::string& sort_order) {
|
||||
@ -187,10 +187,17 @@ size_t facet_index_t::intersect(facet& a_facet,
|
||||
auto facet_str = facet_count_it->facet_value;
|
||||
transform(facet_str.begin(), facet_str.end(), facet_str.begin(), ::tolower);
|
||||
|
||||
for(const auto& searched_token: fvalue_searched_tokens) {
|
||||
if(facet_str.find(searched_token) != std::string::npos) {
|
||||
for(const auto& searched_tokens : fvalue_searched_tokens) {
|
||||
uint16_t found_tokens_count = 0;
|
||||
for (const auto &searched_token: searched_tokens) {
|
||||
if (facet_str.find(searched_token) != std::string::npos) {
|
||||
found_tokens_count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (found_tokens_count == searched_tokens.size()) {
|
||||
a_facet.fvalue_tokens[facet_count_it->facet_value] = searched_tokens;
|
||||
found_search_token = true;
|
||||
a_facet.fvalue_tokens[facet_count_it->facet_value] = fvalue_searched_tokens;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -5166,9 +5166,7 @@ void Index::compute_facet_infos(const std::vector<facet>& facets, facet_query_t&
|
||||
// need to ensure that document ID actually contains searched_query tokens
|
||||
// since `field_result_ids` contains documents matched across all queries
|
||||
// value based index
|
||||
for(const auto& val : searched_tokens) {
|
||||
facet_infos[findex].fvalue_searched_tokens.emplace_back(val);
|
||||
}
|
||||
facet_infos[findex].fvalue_searched_tokens.emplace_back(searched_tokens);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user