Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
docs(search): note quick-search relaxed attribute matching
perfectra1ndf35407b04e4
diff --git a/docs/User Guide/User Guide/Basic Concepts and Features/Navigation/Search.md b/docs/User Guide/User Guide/Basic Concepts and Features/Navigation/Search.mdindex 6e0262af12..1d13e0fd98 100644--- a/docs/User Guide/User Guide/Basic Concepts and Features/Navigation/Search.md+++ b/docs/User Guide/User Guide/Basic Concepts and Features/Navigation/Search.md@@ -122,6 +122,8 @@ The examples below assume four notes: _Austria_ (`#capital=Vienna`), _Somewhere_| `#capital!=Vienna` | `Prague` | Yes | `!=` matches every value that is not `Vienna` || `#capital!=Vienna` | `Vienna` | No | `!=` excludes the exact value |+> **Quick search relaxes this.** The [Quick search](Quick%20search.md) bar and autocomplete apply relaxed attribute matching — an attribute `=` is treated as "contains" — so `#capital=Vienna` typed there also matches `Vienna Austria`; the strict full-value equality described here applies only in the full Search.+### Fuzzy operators (`~=` and `~*`)**Rule:** the fuzzy operators tolerate typos. `~=` (fuzzy-equals) matches a value that is a close whole-word variant of your term; `~*` (fuzzy-contains) matches when your term appears — as a fragment _or_ a near-miss — anywhere inside the value. Both work on note properties (`note.title`, `note.content`, …) and on labels (`#label`). Fuzzy operators require at least 3 characters.diff --git a/packages/trilium-core/src/services/search/docs_examples.spec.ts b/packages/trilium-core/src/services/search/docs_examples.spec.tsindex 68f4dc7924..6056179ea0 100644--- a/packages/trilium-core/src/services/search/docs_examples.spec.ts+++ b/packages/trilium-core/src/services/search/docs_examples.spec.ts@@ -166,6 +166,22 @@ describe("Search documentation examples", () => {expect(findNoteByTitle(results, "Switzerland")).toBeTruthy();expect(results.length).toEqual(1);});++ // Docs: Search.md § "Attribute and property equality" — quick-search caveat.+ // Quick search / autocomplete run with fuzzyAttributeSearch, which rewrites attribute `=`+ // to `*=*` (contains); the same `#capital=Vienna` that is strict in full search also+ // matches the substring value `Vienna Austria` there.+ it("quick search relaxes attribute `=` to a substring match (`#capital=Vienna` also matches `Vienna Austria`)", () => {+ buildCapitals();++ const results = searchService.findResultsWithQuery(+ "#capital=Vienna",+ new SearchContext({ fuzzyAttributeSearch: true })+ );++ expect(findNoteByTitle(results, "Austria")).toBeTruthy();+ expect(findNoteByTitle(results, "Somewhere")).toBeTruthy();+ });});describe('Fuzzy operators (~= fuzzy-equals, ~* fuzzy-contains)', () => {