[search] [bookmarks] Limited the number of bookmark results.

This commit is contained in:
Maxim Pimenov 2019-09-03 15:16:53 +03:00 committed by Aleksey Belousov
parent 2aea4ca36c
commit 76f3d277a6
2 changed files with 9 additions and 0 deletions

View file

@ -261,8 +261,14 @@ void Processor::Search(Params const & params) const
BailIfCancelled();
sort(idInfos.begin(), idInfos.end());
size_t numEmitted = 0;
for (auto const & idInfo : idInfos)
{
if (numEmitted >= params.m_maxNumResults)
break;
m_emitter.AddBookmarkResult(bookmarks::Result(idInfo.m_id));
++numEmitted;
}
}
uint64_t Processor::GetNumDocs(strings::UniString const & token, bool isPrefix) const

View file

@ -8,6 +8,7 @@
#include "search/feature_offset_match.hpp"
#include "search/idf_map.hpp"
#include "search/query_params.hpp"
#include "search/search_params.hpp"
#include "search/utils.hpp"
#include "indexer/search_string_utils.hpp"
@ -38,6 +39,8 @@ public:
{
// If valid, only show results with bookmarks attached to |m_groupId|.
GroupId m_groupId = kInvalidGroupId;
size_t m_maxNumResults = SearchParams::kDefaultNumResultsEverywhere;
};
Processor(Emitter & emitter, base::Cancellable const & cancellable);