From 6efdc4396450c7e2ca66ac5d4ee14f0c9b72b7a4 Mon Sep 17 00:00:00 2001 From: Matthieu Gautier Date: Wed, 7 Feb 2024 17:34:08 +0100 Subject: [PATCH] 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`. --- src/library.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/library.cpp b/src/library.cpp index 0e88867d3..8facc89b2 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -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 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);