mirror of https://github.com/kiwix/libkiwix.git
Merge pull request #506 from kiwix/library_filtering_by_empty_query
Empty query acts as a match-all query
This commit is contained in:
commit
6aab9b6981
|
@ -327,7 +327,7 @@ bool willSelectEverything(const Xapian::Query& query)
|
|||
|
||||
Xapian::Query buildXapianQueryFromFilterQuery(const Filter& filter)
|
||||
{
|
||||
if ( !filter.hasQuery() ) {
|
||||
if ( !filter.hasQuery() || filter.getQuery().empty() ) {
|
||||
// This is a thread-safe way to construct an equivalent of
|
||||
// a Xapian::Query::MatchAll query
|
||||
return Xapian::Query(std::string());
|
||||
|
|
|
@ -479,6 +479,24 @@ TEST_F(LibraryTest, filterByQuery)
|
|||
}
|
||||
|
||||
|
||||
TEST_F(LibraryTest, filteringByEmptyQueryReturnsAllEntries)
|
||||
{
|
||||
EXPECT_FILTER_RESULTS(kiwix::Filter().query(""),
|
||||
"An example ZIM archive",
|
||||
"Encyclopédie de la Tunisie",
|
||||
"Granblue Fantasy Wiki",
|
||||
"Géographie par Wikipédia",
|
||||
"Islam Stack Exchange",
|
||||
"Mathématiques",
|
||||
"Movies & TV Stack Exchange",
|
||||
"Mythology & Folklore Stack Exchange",
|
||||
"Ray Charles",
|
||||
"TED talks - Business",
|
||||
"Tania Louis",
|
||||
"Wikiquote"
|
||||
);
|
||||
}
|
||||
|
||||
TEST_F(LibraryTest, filterByCreator)
|
||||
{
|
||||
EXPECT_FILTER_RESULTS(kiwix::Filter().creator("Wikipedia"),
|
||||
|
|
Loading…
Reference in New Issue