1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-11-27 08:21:03 +02:00

Api: Search for partial matches by default, unless the query is surrounded by quotes

This commit is contained in:
Laurent Cozic 2023-11-19 11:44:34 +00:00
parent 8a533b2003
commit 401d551daa

View File

@ -5,7 +5,7 @@ import { ErrorBadRequest, ErrorMethodNotAllowed } from '../utils/errors';
import requestFields from '../utils/requestFields';
import collectionToPaginatedResults from '../utils/collectionToPaginatedResults';
import BaseItem from '../../../models/BaseItem';
import SearchEngineUtils from '../../searchengine/SearchEngineUtils';
import SearchEngineUtils, { NotesForQueryOptions } from '../../searchengine/SearchEngineUtils';
export default async function(request: Request) {
if (request.method !== 'GET') throw new ErrorMethodNotAllowed();
@ -28,7 +28,11 @@ export default async function(request: Request) {
options.caseInsensitive = true;
results = await ModelClass.all(options);
} else {
results = await SearchEngineUtils.notesForQuery(query, false, defaultLoadOptions(request, ModelType.Note));
const options: NotesForQueryOptions = {
...defaultLoadOptions(request, ModelType.Note),
appendWildCards: true,
};
results = await SearchEngineUtils.notesForQuery(query, false, options);
}
return collectionToPaginatedResults(modelType, results, request);