mirror of
https://github.com/kiwix/libkiwix.git
synced 2025-08-03 02:06:05 -04:00
Correcly search for book's title with double quote (").
At indexation time, double quote are ignored, so a title as `TED "talks" - Business` is indexed as `ted talks business`. By removing the quotes, we ensure that our title "phrase" is not closed too early and we correctly search for `ted PHRASE talks PHRASE business` instead of `ted AND talks AND business`.
This commit is contained in:
parent
7a0ab3a429
commit
6efdc43964
@ -191,6 +191,11 @@ void Library::cleanupBookCollection(BookIdCollection& books, const std::string&
|
||||
}
|
||||
}
|
||||
|
||||
std::string remove_quote(std::string input) {
|
||||
std::replace(input.begin(), input.end(), '"', ' ');
|
||||
return input;
|
||||
}
|
||||
|
||||
std::string Library::getBestTargetBookId(const Bookmark& bookmark, MigrationMode migrationMode) const {
|
||||
std::lock_guard<std::recursive_mutex> lock(m_mutex);
|
||||
// Search for a existing book with the same name
|
||||
@ -204,7 +209,7 @@ std::string Library::getBestTargetBookId(const Bookmark& bookmark, MigrationMode
|
||||
// No bookName nor bookTitle, no way to find target book.
|
||||
return "";
|
||||
}
|
||||
book_filter.query("title:\""+bookmark.getBookTitle() + "\"");
|
||||
book_filter.query("title:\"" + remove_quote(bookmark.getBookTitle()) + "\"");
|
||||
}
|
||||
auto targetBooks = filter(book_filter);
|
||||
cleanupBookCollection(targetBooks, bookmark.getBookId(), migrationMode);
|
||||
|
Loading…
x
Reference in New Issue
Block a user