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:
Matthieu Gautier 2024-02-07 17:34:08 +01:00
parent 7a0ab3a429
commit 6efdc43964
1 changed files with 6 additions and 1 deletions

View File

@ -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);