diff --git a/lib_vector_search/src/grouped_finder.cpp b/lib_vector_search/src/grouped_finder.cpp index 3b4243f..81ec7f8 100644 --- a/lib_vector_search/src/grouped_finder.cpp +++ b/lib_vector_search/src/grouped_finder.cpp @@ -22,7 +22,8 @@ GroupedFinder::find_prefix(std::string_view search_term) const { const auto word_list = group->second; const auto word_list_size = word_list.size(); - const auto thread_count = std::thread::hardware_concurrency(); + const auto thread_count = + std::min(std::thread::hardware_concurrency(), word_list_size); forward_list matching_words; mutex matching_words_mutex;