Fixed search returning duplicates

This commit is contained in:
ByteHamster 2020-02-04 23:50:38 +01:00
parent 6b82cfdd96
commit 50dd85276c
3 changed files with 4 additions and 17 deletions

View File

@ -47,16 +47,10 @@ public class FeedSearcher {
SearchLocation location; SearchLocation location;
if (safeContains(item.getTitle(), query)) { if (safeContains(item.getTitle(), query)) {
location = SearchLocation.TITLE; location = SearchLocation.TITLE;
} else if (safeContains(item.getContentEncoded(), query)) {
location = SearchLocation.SHOWNOTES;
} else if (safeContains(item.getDescription(), query)) {
location = SearchLocation.SHOWNOTES;
} else if (safeContains(item.getChapters(), query)) { } else if (safeContains(item.getChapters(), query)) {
location = SearchLocation.CHAPTERS; location = SearchLocation.CHAPTERS;
} else if (safeContains(item.getFeed().getAuthor(), query)) {
location = SearchLocation.AUTHORS;
} else { } else {
location = SearchLocation.FEED; location = SearchLocation.SHOWNOTES;
} }
result.add(new SearchResult(item, location)); result.add(new SearchResult(item, location));
} }

View File

@ -1273,20 +1273,15 @@ public class PodDBAdapter {
queryFeedId = "1 = 1"; queryFeedId = "1 = 1";
} }
String query = "SELECT " + SEL_FI_SMALL_STR + " FROM " + TABLE_NAME_FEED_ITEMS String query = "SELECT DISTINCT " + SEL_FI_SMALL_STR + " FROM " + TABLE_NAME_FEED_ITEMS
+ " LEFT JOIN " + TABLE_NAME_SIMPLECHAPTERS + " LEFT JOIN " + TABLE_NAME_SIMPLECHAPTERS
+ " ON " + TABLE_NAME_SIMPLECHAPTERS + "." + KEY_FEEDITEM + " ON " + TABLE_NAME_SIMPLECHAPTERS + "." + KEY_FEEDITEM
+ "=" + TABLE_NAME_FEED_ITEMS + "." + KEY_ID + "=" + TABLE_NAME_FEED_ITEMS + "." + KEY_ID
+ " LEFT JOIN " + TABLE_NAME_FEEDS
+ " ON " + TABLE_NAME_FEED_ITEMS + "." + KEY_FEED
+ "=" + TABLE_NAME_FEEDS + "." + KEY_ID
+ " WHERE " + queryFeedId + " AND (" + " WHERE " + queryFeedId + " AND ("
+ TABLE_NAME_FEED_ITEMS + "." + KEY_DESCRIPTION + " LIKE '%" + preparedQuery + "%' OR " + TABLE_NAME_FEED_ITEMS + "." + KEY_DESCRIPTION + " LIKE '%" + preparedQuery + "%' OR "
+ TABLE_NAME_FEED_ITEMS + "." + KEY_CONTENT_ENCODED + " LIKE '%" + preparedQuery + "%' OR " + TABLE_NAME_FEED_ITEMS + "." + KEY_CONTENT_ENCODED + " LIKE '%" + preparedQuery + "%' OR "
+ TABLE_NAME_FEED_ITEMS + "." + KEY_TITLE + " LIKE '%" + preparedQuery + "%' OR " + TABLE_NAME_FEED_ITEMS + "." + KEY_TITLE + " LIKE '%" + preparedQuery + "%' OR "
+ TABLE_NAME_SIMPLECHAPTERS + "." + KEY_TITLE + " LIKE '%" + preparedQuery + "%' OR " + TABLE_NAME_SIMPLECHAPTERS + "." + KEY_TITLE + " LIKE '%" + preparedQuery + "%'"
+ TABLE_NAME_FEEDS + "." + KEY_AUTHOR + " LIKE '%" + preparedQuery + "%' OR "
+ TABLE_NAME_FEEDS + "." + KEY_FEED_IDENTIFIER + " LIKE '%" + preparedQuery + "%'"
+ ") ORDER BY " + KEY_PUBDATE + " DESC " + ") ORDER BY " + KEY_PUBDATE + " DESC "
+ "LIMIT 500"; + "LIMIT 500";
return db.rawQuery(query, null); return db.rawQuery(query, null);

View File

@ -6,9 +6,7 @@ import de.danoeh.antennapod.core.R;
public enum SearchLocation { public enum SearchLocation {
TITLE(R.string.found_in_title_label), TITLE(R.string.found_in_title_label),
CHAPTERS(R.string.found_in_chapters_label), CHAPTERS(R.string.found_in_chapters_label),
SHOWNOTES(R.string.found_in_shownotes_label), SHOWNOTES(R.string.found_in_shownotes_label);
AUTHORS(R.string.found_in_authors_label),
FEED(R.string.found_in_feeds_label);
private int description; private int description;
SearchLocation(@StringRes int description) { SearchLocation(@StringRes int description) {