mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
better error reporting on failed search
This commit is contained in:
parent
2b1383205b
commit
bdebb35f62
@ -165,7 +165,7 @@ export default class Entrypoints extends Component {
|
||||
const response = await server.get('search/' + encodeURIComponent(searchText) + '?includeNoteContent=true&excludeArchived=true&fuzzyAttributeSearch=false');
|
||||
|
||||
if (!response.success) {
|
||||
toastService.showError("Search failed.", 3000);
|
||||
toastService.showError("Search failed: " + response.message, 10000);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,8 @@ function searchNotes(req) {
|
||||
|
||||
try {
|
||||
return {
|
||||
success: true,
|
||||
success: !searchContext.hasError(),
|
||||
message: searchContext.getError(),
|
||||
count,
|
||||
results
|
||||
}
|
||||
|
@ -16,6 +16,14 @@ class SearchContext {
|
||||
this.error = error;
|
||||
}
|
||||
}
|
||||
|
||||
hasError() {
|
||||
return !!this.error;
|
||||
}
|
||||
|
||||
getError() {
|
||||
return this.error;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = SearchContext;
|
||||
|
@ -263,7 +263,13 @@ function getExpression(tokens, searchContext, level = 0) {
|
||||
i += 1;
|
||||
|
||||
return new RelationWhereExp(relationName, parseNoteProperty());
|
||||
} else {
|
||||
}
|
||||
else if (i < tokens.length - 2 && isOperator(tokens[i + 1].token)) {
|
||||
searchContext.addError(`Relation can be compared only with property, e.g. ~relation.title=hello in ${context(i)}`);
|
||||
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
return new AttributeExistsExp('relation', relationName, searchContext.fuzzyAttributeSearch);
|
||||
}
|
||||
}
|
||||
|
@ -73,6 +73,8 @@ function findNotesWithQuery(query, searchContext) {
|
||||
return [];
|
||||
}
|
||||
|
||||
searchContext.originalQuery = query;
|
||||
|
||||
return utils.stopWatch(`Search with query "${query}"`, () => {
|
||||
const expression = parseQueryToExpression(query, searchContext);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user