1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Merge branch 'dev' of github.com:laurent22/joplin into dev

This commit is contained in:
Laurent Cozic 2021-06-25 09:28:26 +01:00
commit 8e35841d79
6 changed files with 22 additions and 16 deletions

View File

@ -1397,6 +1397,9 @@ packages/lib/services/searchengine/SearchEngineUtils.test.js.map
packages/lib/services/searchengine/filterParser.d.ts
packages/lib/services/searchengine/filterParser.js
packages/lib/services/searchengine/filterParser.js.map
packages/lib/services/searchengine/filterParser.test.d.ts
packages/lib/services/searchengine/filterParser.test.js
packages/lib/services/searchengine/filterParser.test.js.map
packages/lib/services/searchengine/queryBuilder.d.ts
packages/lib/services/searchengine/queryBuilder.js
packages/lib/services/searchengine/queryBuilder.js.map

3
.gitignore vendored
View File

@ -1383,6 +1383,9 @@ packages/lib/services/searchengine/SearchEngineUtils.test.js.map
packages/lib/services/searchengine/filterParser.d.ts
packages/lib/services/searchengine/filterParser.js
packages/lib/services/searchengine/filterParser.js.map
packages/lib/services/searchengine/filterParser.test.d.ts
packages/lib/services/searchengine/filterParser.test.js
packages/lib/services/searchengine/filterParser.test.js.map
packages/lib/services/searchengine/queryBuilder.d.ts
packages/lib/services/searchengine/queryBuilder.js
packages/lib/services/searchengine/queryBuilder.js.map

View File

@ -453,6 +453,8 @@ The filters are implicitly connected by and/or connectives depending on the foll
- To override this default behaviour, use the `any` filter, in which case the search terms will be connected by "OR" instead.
- There's an exception for the `notebook` filters which are connected by "OR". The reason being that no note can be in multiple notebooks at once.
Incorrect search filters are interpreted as a phrase search, e.g. misspelled `nootebook:Example` or non-existing `https://joplinapp.org`.
## Search order
Notes are sorted by "relevance". Currently it means the notes that contain the requested terms the most times are on top. For queries with multiple terms, it also matters how close to each other the terms are. This is a bit experimental so if you notice a search query that returns unexpected results, please report it in the forum, providing as many details as possible to replicate the issue.

View File

@ -18,9 +18,6 @@
Apps targeting Android 10 (sdk 29) can no longer freely access arbitrary paths on the shared storage.
This attribute allows to opt out of this restriction.
android:allowBackup: used to enable Android Backup which some users need:
https://github.com/laurent22/joplin/issues/4020
android:resizeableActivity: allows user to resize Joplin window
https://github.com/laurent22/joplin/issues/3547
-->
@ -29,7 +26,7 @@
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="true"
android:allowBackup="false"
android:networkSecurityConfig="@xml/network_security_config"
android:requestLegacyExternalStorage="true"
android:resizeableActivity="true"

View File

@ -1,11 +1,8 @@
/* eslint-disable no-unused-vars */
import filterParser from './filterParser';
const filterParser = require('../../services/searchengine/filterParser.js').default;
// import filterParser from '../../services/searchengine/filterParser.js';
const makeTerm = (name, value, negated, quoted = false, wildcard = false) => {
const makeTerm = (name: string, value: string, negated: boolean, quoted: boolean = false, wildcard: boolean = false) => {
if (name === 'text') { return { name, value, negated, quoted, wildcard }; }
if (name === 'title' | name === 'body') { return { name, value, negated, wildcard }; }
if (name === 'title' || name === 'body') { return { name, value, negated, wildcard }; }
return { name, value, negated };
};
@ -135,13 +132,16 @@ describe('filterParser should be correct filter for keyword', () => {
it('handle invalid filters', () => {
let searchString = 'titletitle:123';
expect(() => filterParser(searchString)).toThrow(new Error('Invalid filter: titletitle'));
expect(filterParser(searchString)).toContainEqual(makeTerm('text', '"titletitle:123"', false));
searchString = 'invalid:abc';
expect(() => filterParser(searchString)).toThrow(new Error('Invalid filter: invalid'));
expect(filterParser(searchString)).toContainEqual(makeTerm('text', '"invalid:abc"', false));
searchString = '-invalid:abc';
expect(filterParser(searchString)).toContainEqual(makeTerm('text', '"invalid:abc"', true));
searchString = ':abc';
expect(() => filterParser(searchString)).toThrow(new Error('Invalid filter: '));
expect(filterParser(searchString)).toContainEqual(makeTerm('text', '":abc"', false));
searchString = 'type:blah';
expect(() => filterParser(searchString)).toThrow(new Error('The value of filter "type" must be "note" or "todo"'));

View File

@ -22,7 +22,7 @@ const quote = (s: string) => {
};
const getTerms = (query: string): Term[] => {
const getTerms = (query: string, validFilters: Set<string>): Term[] => {
const terms: Term[] = [];
let inQuote = false;
let inTerm = false;
@ -52,7 +52,8 @@ const getTerms = (query: string): Term[] => {
continue;
}
if (c === ':' && !inQuote && !inTerm) {
if (c === ':' && !inQuote && !inTerm &&
(validFilters.has(currentTerm) || currentTerm[0] === '-' && validFilters.has(currentTerm.substr(1, currentTerm.length)))) {
currentCol = currentTerm;
currentTerm = '';
inTerm = true; // to ignore any other ':' before a space eg.'sourceurl:https://www.google.com'
@ -71,7 +72,7 @@ const parseQuery = (query: string): Term[] => {
'iscompleted', 'due', 'latitude', 'longitude',
'altitude', 'resource', 'sourceurl', 'id']);
const terms = getTerms(query);
const terms = getTerms(query, validFilters);
const result: Term[] = [];
for (let i = 0; i < terms.length; i++) {