Initial version of Xapian-based catalog search

This commit is contained in:
Veloman Yunkan
2021-03-07 01:11:04 +04:00
committed by Matthieu Gautier
parent a17fc0ef2d
commit a599fb3892
4 changed files with 104 additions and 8 deletions

View File

@ -263,7 +263,7 @@ TEST_F(LibraryTest, filterCheck)
bookIds = lib.filter(kiwix::Filter().query("folklore"));
EXPECT_EQ(bookIds.size(), 1U);
bookIds = lib.filter(kiwix::Filter().query("Wiki"));
bookIds = lib.filter(kiwix::Filter().query("Wiki*"));
EXPECT_EQ(bookIds.size(), 4U);
bookIds = lib.filter(kiwix::Filter().query("Wiki").creator("Wiki"));

View File

@ -733,7 +733,26 @@ TEST_F(LibraryServerTest, catalog_searchdescription_xml)
);
}
TEST_F(LibraryServerTest, catalog_search_by_text)
TEST_F(LibraryServerTest, catalog_search_by_phrase)
{
const auto r = zfs1_->GET("/catalog/search?q=\"ray%20charles\"");
EXPECT_EQ(r->status, 200);
EXPECT_EQ(maskVariableOPDSFeedData(r->body),
OPDS_FEED_TAG
" <id>12345678-90ab-cdef-1234-567890abcdef</id>\n"
" <title>Search result for \"ray charles\"</title>\n"
" <updated>YYYY-MM-DDThh:mm:ssZ</updated>\n"
" <totalResults>2</totalResults>\n"
" <startIndex>0</startIndex>\n"
" <itemsPerPage>2</itemsPerPage>\n"
CATALOG_LINK_TAGS
RAY_CHARLES_CATALOG_ENTRY
UNCATEGORIZED_RAY_CHARLES_CATALOG_ENTRY
"</feed>\n"
);
}
TEST_F(LibraryServerTest, catalog_search_by_words)
{
const auto r = zfs1_->GET("/catalog/search?q=ray%20charles");
EXPECT_EQ(r->status, 200);
@ -742,12 +761,13 @@ TEST_F(LibraryServerTest, catalog_search_by_text)
" <id>12345678-90ab-cdef-1234-567890abcdef</id>\n"
" <title>Search result for ray charles</title>\n"
" <updated>YYYY-MM-DDThh:mm:ssZ</updated>\n"
" <totalResults>2</totalResults>\n"
" <totalResults>3</totalResults>\n"
" <startIndex>0</startIndex>\n"
" <itemsPerPage>2</itemsPerPage>\n"
" <itemsPerPage>3</itemsPerPage>\n"
CATALOG_LINK_TAGS
RAY_CHARLES_CATALOG_ENTRY
UNCATEGORIZED_RAY_CHARLES_CATALOG_ENTRY
CHARLES_RAY_CATALOG_ENTRY
"</feed>\n"
);
}