mirror of https://github.com/laurent22/joplin.git
parent
b780a62588
commit
d588bddfaa
|
@ -28,7 +28,6 @@ export default async function(request: Request) {
|
||||||
options.caseInsensitive = true;
|
options.caseInsensitive = true;
|
||||||
results = await ModelClass.all(options);
|
results = await ModelClass.all(options);
|
||||||
} else {
|
} else {
|
||||||
console.info('routes/search: options:', defaultLoadOptions(request, ModelType.Note));
|
|
||||||
results = await SearchEngineUtils.notesForQuery(query, defaultLoadOptions(request, ModelType.Note));
|
results = await SearchEngineUtils.notesForQuery(query, defaultLoadOptions(request, ModelType.Note));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,13 +11,9 @@ class SearchEngineUtils {
|
||||||
searchType = SearchEngine.SEARCH_TYPE_BASIC;
|
searchType = SearchEngine.SEARCH_TYPE_BASIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.info('SearchEngineUtils: search type', searchType);
|
|
||||||
|
|
||||||
const results = await SearchEngine.instance().search(query, { searchType });
|
const results = await SearchEngine.instance().search(query, { searchType });
|
||||||
const noteIds = results.map(n => n.id);
|
const noteIds = results.map(n => n.id);
|
||||||
|
|
||||||
console.info('SearchEngineUtils: results', results);
|
|
||||||
|
|
||||||
// We need at least the note ID to be able to sort them below so if not
|
// We need at least the note ID to be able to sort them below so if not
|
||||||
// present in field list, add it.L Also remember it was auto-added so that
|
// present in field list, add it.L Also remember it was auto-added so that
|
||||||
// it can be removed afterwards.
|
// it can be removed afterwards.
|
||||||
|
@ -34,12 +30,8 @@ class SearchEngineUtils {
|
||||||
conditions: [`id IN ("${noteIds.join('","')}")`],
|
conditions: [`id IN ("${noteIds.join('","')}")`],
|
||||||
}, options);
|
}, options);
|
||||||
|
|
||||||
console.info('SearchEngineUtils: previewOptions', previewOptions);
|
|
||||||
|
|
||||||
const notes = await Note.previews(null, previewOptions);
|
const notes = await Note.previews(null, previewOptions);
|
||||||
|
|
||||||
console.info('SearchEngineUtils: notes', notes);
|
|
||||||
|
|
||||||
// By default, the notes will be returned in reverse order
|
// By default, the notes will be returned in reverse order
|
||||||
// or maybe random order so sort them here in the correct order
|
// or maybe random order so sort them here in the correct order
|
||||||
// (search engine returns the results in order of relevance).
|
// (search engine returns the results in order of relevance).
|
||||||
|
@ -50,7 +42,6 @@ class SearchEngineUtils {
|
||||||
if (idWasAutoAdded) delete sortedNotes[idx].id;
|
if (idWasAutoAdded) delete sortedNotes[idx].id;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.info('SearchEngineUtils: sortedNotes', sortedNotes);
|
|
||||||
|
|
||||||
// Note that when the search engine index is somehow corrupted, it might contain
|
// Note that when the search engine index is somehow corrupted, it might contain
|
||||||
// references to notes that don't exist. Not clear how it can happen, but anyway
|
// references to notes that don't exist. Not clear how it can happen, but anyway
|
||||||
|
|
Loading…
Reference in New Issue