mirror of
https://github.com/typesense/typesense.git
synced 2025-05-21 22:33:27 +08:00
Fix rogue group limit config regression.
This commit is contained in:
parent
3447c81f5d
commit
3fe3a6ca7a
@ -390,7 +390,7 @@ public:
|
||||
const std::string& pinned_hits_str="",
|
||||
const std::string& hidden_hits="",
|
||||
const std::vector<std::string>& group_by_fields={},
|
||||
const size_t group_limit = 0,
|
||||
size_t group_limit = 3,
|
||||
const std::string& highlight_start_tag="<mark>",
|
||||
const std::string& highlight_end_tag="</mark>",
|
||||
std::vector<uint32_t> query_by_weights={},
|
||||
|
@ -683,7 +683,7 @@ Option<nlohmann::json> Collection::search(const std::string & raw_query, const s
|
||||
const std::string& pinned_hits_str,
|
||||
const std::string& hidden_hits_str,
|
||||
const std::vector<std::string>& group_by_fields,
|
||||
const size_t group_limit,
|
||||
size_t group_limit,
|
||||
const std::string& highlight_start_tag,
|
||||
const std::string& highlight_end_tag,
|
||||
std::vector<uint32_t> query_by_weights,
|
||||
@ -741,6 +741,10 @@ Option<nlohmann::json> Collection::search(const std::string & raw_query, const s
|
||||
}
|
||||
}
|
||||
|
||||
if(group_by_fields.empty()) {
|
||||
group_limit = 0;
|
||||
}
|
||||
|
||||
// process weights for search fields
|
||||
std::vector<search_field_t> weighted_search_fields;
|
||||
size_t max_weight = 20;
|
||||
@ -1048,7 +1052,7 @@ Option<nlohmann::json> Collection::search(const std::string & raw_query, const s
|
||||
populate_result_kvs(&curated_topster, override_result_kvs);
|
||||
|
||||
// for grouping we have to aggregate group set sizes to a count value
|
||||
if(!group_by_fields.empty()) {
|
||||
if(group_limit) {
|
||||
for(auto& acc_facet: facets) {
|
||||
for(auto& facet_kv: acc_facet.result_map) {
|
||||
facet_kv.second.count = acc_facet.hash_groups[facet_kv.first].size();
|
||||
@ -1172,7 +1176,7 @@ Option<nlohmann::json> Collection::search(const std::string & raw_query, const s
|
||||
result["out_of"] = num_documents.load();
|
||||
}
|
||||
|
||||
std::string hits_key = !group_by_fields.empty() ? "grouped_hits" : "hits";
|
||||
std::string hits_key = group_limit ? "grouped_hits" : "hits";
|
||||
result[hits_key] = nlohmann::json::array();
|
||||
|
||||
// construct results array
|
||||
@ -1180,11 +1184,11 @@ Option<nlohmann::json> Collection::search(const std::string & raw_query, const s
|
||||
const std::vector<KV*> & kv_group = result_group_kvs[result_kvs_index];
|
||||
|
||||
nlohmann::json group_hits;
|
||||
if(!group_by_fields.empty()) {
|
||||
if(group_limit) {
|
||||
group_hits["hits"] = nlohmann::json::array();
|
||||
}
|
||||
|
||||
nlohmann::json& hits_array = !group_by_fields.empty() ? group_hits["hits"] : result["hits"];
|
||||
nlohmann::json& hits_array = group_limit ? group_hits["hits"] : result["hits"];
|
||||
|
||||
for(const KV* field_order_kv: kv_group) {
|
||||
const std::string& seq_id_key = get_seq_id_key((uint32_t) field_order_kv->key);
|
||||
@ -1275,7 +1279,7 @@ Option<nlohmann::json> Collection::search(const std::string & raw_query, const s
|
||||
hits_array.push_back(wrapper_doc);
|
||||
}
|
||||
|
||||
if(!group_by_fields.empty()) {
|
||||
if(group_limit) {
|
||||
const auto& document = group_hits["hits"][0]["document"];
|
||||
|
||||
group_hits["group_key"] = nlohmann::json::array();
|
||||
|
Loading…
x
Reference in New Issue
Block a user