1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-01-29 19:13:59 +02:00

Mobile: Fixes #9905: Fix full text search broken on Android 7 and earlier (#9914)

This commit is contained in:
Henry Heino 2024-02-12 06:43:01 -08:00 committed by GitHub
parent 3000afca49
commit cb21a91fac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -777,18 +777,29 @@ export default class SearchEngine {
if (!queryHasFilters) {
const toSearch = parsedQuery.allTerms.map(t => t.value).join(' ');
let itemRows = await this.db().selectAll<ProcessResultsRow>(`
SELECT
id,
title,
user_updated_time,
offsets(items_fts) AS offsets,
matchinfo(items_fts, 'pcnalx') AS matchinfo,
item_id,
item_type
FROM items_fts
WHERE title MATCH ? OR body MATCH ?
`, [toSearch, toSearch]);
let itemRows: ProcessResultsRow[] = [];
try {
itemRows = await this.db().selectAll<ProcessResultsRow>(`
SELECT
id,
title,
user_updated_time,
offsets(items_fts) AS offsets,
matchinfo(items_fts, 'pcnalx') AS matchinfo,
item_id,
item_type
FROM items_fts
WHERE title MATCH ? OR body MATCH ?
`, [toSearch, toSearch]);
} catch (error) {
// Android <= 25 doesn't support the following syntax:
// WHERE title MATCH ? OR body MATCH ?
// Thus, we skip resource search on these devices.
if (!error.message?.includes?.('unable to use function MATCH in the requested context')) {
throw error;
}
}
const resourcesToNotes = await NoteResource.associatedResourceNotes(itemRows.map(r => r.item_id), { fields: ['note_id', 'parent_id'] });