You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-08-10 22:11:50 +02:00
This commit is contained in:
@@ -594,6 +594,16 @@ const builtInMetadata = (Setting: typeof SettingType) => {
|
|||||||
label: () => _('OCR: Clear cache and re-download language data files'),
|
label: () => _('OCR: Clear cache and re-download language data files'),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'ocr.searchInExtractedContent': {
|
||||||
|
value: true,
|
||||||
|
type: SettingItemType.Bool,
|
||||||
|
advanced: true,
|
||||||
|
public: true,
|
||||||
|
appTypes: [AppType.Desktop],
|
||||||
|
storage: SettingStorage.Database,
|
||||||
|
label: () => _('OCR: Search in extracted content'),
|
||||||
|
},
|
||||||
|
|
||||||
theme: {
|
theme: {
|
||||||
value: Setting.THEME_LIGHT,
|
value: Setting.THEME_LIGHT,
|
||||||
type: SettingItemType.Int,
|
type: SettingItemType.Int,
|
||||||
|
@@ -1,8 +1,10 @@
|
|||||||
import { setupDatabaseAndSynchronizer, db, sleep, switchClient, msleep } from '../../testing/test-utils';
|
import { setupDatabaseAndSynchronizer, db, sleep, switchClient, msleep, createNoteAndResource } from '../../testing/test-utils';
|
||||||
import SearchEngine from './SearchEngine';
|
import SearchEngine from './SearchEngine';
|
||||||
import Note from '../../models/Note';
|
import Note from '../../models/Note';
|
||||||
import ItemChange from '../../models/ItemChange';
|
import ItemChange from '../../models/ItemChange';
|
||||||
import Setting from '../../models/Setting';
|
import Setting from '../../models/Setting';
|
||||||
|
import Resource from '../../models/Resource';
|
||||||
|
import { ResourceOcrStatus } from '../database/types';
|
||||||
|
|
||||||
let engine: SearchEngine = null;
|
let engine: SearchEngine = null;
|
||||||
|
|
||||||
@@ -583,4 +585,32 @@ describe('services/SearchEngine', () => {
|
|||||||
// expect(await engine.search(f1.id)).toEqual([]);
|
// expect(await engine.search(f1.id)).toEqual([]);
|
||||||
// }));
|
// }));
|
||||||
|
|
||||||
|
it.each(
|
||||||
|
[
|
||||||
|
['find', 'enabled', true, 1],
|
||||||
|
['not find', 'disabled', false, 0],
|
||||||
|
],
|
||||||
|
)('should %s resources if searching in OCR content is %s',
|
||||||
|
async (_testName: string, _testName2: string, isSearchEnabled: boolean, resourcesFound: number) => {
|
||||||
|
const { resource } = await createNoteAndResource();
|
||||||
|
await Resource.save({
|
||||||
|
id: resource.id,
|
||||||
|
ocr_status: ResourceOcrStatus.Done,
|
||||||
|
ocr_text: 'héllô, hôw äre yoù ?',
|
||||||
|
});
|
||||||
|
|
||||||
|
await engine.syncTables();
|
||||||
|
|
||||||
|
const normalized = await db().selectAll('select * from items_fts');
|
||||||
|
expect(normalized[0].body).toBe('hello, how are you ?');
|
||||||
|
|
||||||
|
Setting.setValue('ocr.searchInExtractedContent', isSearchEnabled);
|
||||||
|
|
||||||
|
const rows = await engine.search('hello', {
|
||||||
|
searchType: SearchEngine.SEARCH_TYPE_FTS,
|
||||||
|
includeOrphanedResources: true,
|
||||||
|
});
|
||||||
|
expect(rows.length).toBe(resourcesFound);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@@ -815,7 +815,7 @@ export default class SearchEngine {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!queryHasFilters) {
|
if (!queryHasFilters && Setting.value('ocr.searchInExtractedContent')) {
|
||||||
const toSearch = parsedQuery.allTerms.map(t => t.value).join(' ');
|
const toSearch = parsedQuery.allTerms.map(t => t.value).join(' ');
|
||||||
|
|
||||||
let itemRows: ProcessResultsRow[] = [];
|
let itemRows: ProcessResultsRow[] = [];
|
||||||
|
Reference in New Issue
Block a user