Skip to content

Commit

Permalink
Merge pull request #586 from openzim/fix_getTitle
Browse files Browse the repository at this point in the history
Fix getTitle to return the actual title
  • Loading branch information
mgautierfr authored Jul 27, 2021
2 parents 20c0e30 + a87f882 commit 4914541
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
11 changes: 1 addition & 10 deletions src/search_iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,7 @@ std::string SearchIterator::getTitle() const {
if ( ! internal ) {
return "";
}
if ( ! internal->mp_internalDb->hasValuesmap() )
{
/* This is the old legacy version. Guess and try */
return internal->get_document().get_value(0);
}
else if ( internal->mp_internalDb->hasValue("title") )
{
return internal->get_document().get_value(internal->mp_internalDb->valueSlot("title"));
}
return "";
return internal->get_entry().getTitle();
}

int SearchIterator::getScore() const {
Expand Down
8 changes: 8 additions & 0 deletions test/search_iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ TEST(search_iterator, functions) {

zim::Archive archive = tza.createZimFromTitles({
"item a",
"Item B",
"iTem ć"
});

zim::Searcher searcher(archive);
Expand All @@ -118,6 +120,12 @@ TEST(search_iterator, functions) {
ASSERT_EQ(it.getZimId(), archive.getUuid());
ASSERT_EQ(it.getWordCount(), -1); // Unimplemented
ASSERT_EQ(it.getSize(), -1); // Unimplemented

// Check getTitle for accents/cased text
it++;
ASSERT_EQ(it.getTitle(), "Item B");
it++;
ASSERT_EQ(it.getTitle(), "iTem ć");
}

TEST(search_iterator, stemmedSearch) {
Expand Down

0 comments on commit 4914541

Please sign in to comment.