Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix documentation of getResults #597

Merged
merged 2 commits into from
Aug 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions include/zim/search.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ class Search
*
* @param start The begining of the range to get
* (offset of the first result).
* @param end The end of the range to get
* (offset of the result past the end of the range).
* @param maxResults The maximum number of results to return
* (offset of last result from the start of range).
*/
const SearchResultSet getResults(int start, int end) const;
const SearchResultSet getResults(int start, int maxResults) const;

/** Get the number of estimated results for this search.
*
Expand Down
4 changes: 2 additions & 2 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,10 @@ int Search::getEstimatedMatches() const
}
}

const SearchResultSet Search::getResults(int start, int end) const {
const SearchResultSet Search::getResults(int start, int maxResults) const {
try {
auto enquire = getEnquire();
auto mset = enquire.get_mset(start, end);
auto mset = enquire.get_mset(start, maxResults);
return SearchResultSet(mp_internalDb, std::move(mset));
} catch(Xapian::QueryParserError& e) {
return SearchResultSet(mp_internalDb);
Expand Down
8 changes: 8 additions & 0 deletions test/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ TEST(Search, multiSearch)
it1++;it1++;it1++;
ASSERT_EQ(it1, result1.end());

// Check result retrieval in start ranges
auto result2 = search0.getResults(0, 3); // Should return 3 results
ASSERT_EQ(result2.size(), 3);

// Check result retrieval in middle ranges
auto result3 = search0.getResults(2, 3); // Should Return 3 result
ASSERT_EQ(result3.size(), 3);

// Be able to do a different search using the same searcher.
query.setQuery("super", false);
auto search1 = searcher.search(query);
Expand Down