From 624c6ded2682e36047fa81ea39d6e2488f7e1211 Mon Sep 17 00:00:00 2001 From: krunal Date: Thu, 26 Oct 2023 13:55:12 +0530 Subject: [PATCH] fix facet_query check with updated facets param --- src/collection.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/collection.cpp b/src/collection.cpp index 112e322c..8a5615b6 100644 --- a/src/collection.cpp +++ b/src/collection.cpp @@ -1800,7 +1800,14 @@ Option Collection::search(std::string raw_query, } else { // facet query field must be part of facet fields requested facet_query = { StringUtils::trim(facet_query_fname), facet_query_value }; - if(std::find(facet_fields.begin(), facet_fields.end(), facet_query.field_name) == facet_fields.end()) { + bool found = false; + for(const auto& facet : facets) { + if(facet.field_name == facet_query.field_name) { + found=true; + break; + } + } + if(!found) { std::string error = "Facet query refers to a facet field `" + facet_query.field_name + "` " + "that is not part of `facet_by` parameter."; return Option(400, error);