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
fix(search): keep a code note's excerpt as code
Elian Doranc663cbd5251d
diff --git a/apps/client/src/widgets/collections/search/SearchResultCard.tsx b/apps/client/src/widgets/collections/search/SearchResultCard.tsxindex a85cec14e8..3dae4e8919 100644--- a/apps/client/src/widgets/collections/search/SearchResultCard.tsx+++ b/apps/client/src/widgets/collections/search/SearchResultCard.tsx@@ -41,6 +41,7 @@ export default function SearchResultCard({ noteId, details, loading, highlightedconst href = calculateHash({ notePath: noteId, viewScope });const hasDetails = !!details || loading;const canExpand = !!details?.contentSnippetTruncated;+ const noteType = note?.type;const [ expanded, setExpanded ] = useState(false);const [ contentReady, setContentReady ] = useState(false);const contentRef = useRef<HTMLDivElement>(null);@@ -101,7 +102,7 @@ export default function SearchResultCard({ noteId, details, loading, highlighted<div className="search-result-card-content" ref={contentRef}>{expanded && note ? (<>- {!contentReady && <SearchResultSnippet details={details} loading={loading} />}+ {!contentReady && <SearchResultSnippet details={details} loading={loading} noteType={noteType} />}<NoteContentnote={note}noChildrenList@@ -112,7 +113,7 @@ export default function SearchResultCard({ noteId, details, loading, highlighted/></>) : (- <SearchResultSnippet details={details} loading={loading} />+ <SearchResultSnippet details={details} loading={loading} noteType={noteType} />)}{canExpand && (<LinkButton@@ -165,7 +166,7 @@ function animateHeight(element: HTMLElement, from: number, to: number) {animation.oncancel = settle;}-function SearchResultSnippet({ details, loading }: { details: SearchResultDetails | undefined; loading: boolean }) {+function SearchResultSnippet({ details, loading, noteType }: { details: SearchResultDetails | undefined; loading: boolean; noteType?: string }) {if (!details) {// Details for this page haven't arrived yet: show a skeleton, or nothing once settled.return loading ? <div className="search-result-card-snippet skeleton" /> : null;@@ -177,7 +178,7 @@ function SearchResultSnippet({ details, loading }: { details: SearchResultDetail}// Server snippet is pre-escaped with only <b>/<br> injected (same trust level as quick search).- return <RawHtmlBlock className="search-result-card-snippet" html={details.highlightedContentSnippet ?? ""} />;+ return <RawHtmlBlock className={clsx("search-result-card-snippet", noteType && `type-${noteType}`)} html={details.highlightedContentSnippet ?? ""} />;}/**diff --git a/apps/client/src/widgets/collections/search/SearchResultsList.css b/apps/client/src/widgets/collections/search/SearchResultsList.cssindex cd81801639..1b69a232bb 100644--- a/apps/client/src/widgets/collections/search/SearchResultsList.css+++ b/apps/client/src/widgets/collections/search/SearchResultsList.css@@ -105,6 +105,11 @@overflow-wrap: anywhere;}+ .search-result-card-snippet.type-code {+ font-family: var(--monospace-font-family);+ white-space: pre-wrap;+ }+.search-result-card-snippet.unavailable {font-style: italic;opacity: 0.7;diff --git a/apps/client/src/widgets/collections/search/SearchResultsList.spec.tsx b/apps/client/src/widgets/collections/search/SearchResultsList.spec.tsxindex e7a5913640..c893e6a0f6 100644--- a/apps/client/src/widgets/collections/search/SearchResultsList.spec.tsx+++ b/apps/client/src/widgets/collections/search/SearchResultsList.spec.tsx@@ -184,6 +184,15 @@ describe("SearchResultCard", () => {expect(container.querySelector(".search-result-card-content")?.textContent).toContain("calendar");});+ it("renders a code note's excerpt in a code font", async () => {+ const note = buildNote({ id: "note1", title: "script.ts", type: "code" });+ await mount(+ <SearchResultCard noteId={note.noteId} details={makeDetails()} loading={false} highlightedTokens={null} />+ );++ expect(container.querySelector(".search-result-card-snippet")?.classList.contains("type-code")).toBe(true);+ });+it("keeps the excerpt while the note it expands to is still rendering", async () => {noteContentState.ready = false;const note = buildNote({ id: "note1", title: "Meeting notes", type: "text" });diff --git a/apps/server/src/assets/help/help_content.json b/apps/server/src/assets/help/help_content.jsonindex 17687a1e95..94c1fcda5a 100644--- a/apps/server/src/assets/help/help_content.json+++ b/apps/server/src/assets/help/help_content.json@@ -83,7 +83,7 @@"_help_MMiBEQljMQh2": "<p>One of the Trilium's goals is to provide fast and comfortable navigation between notes.</p><h2>Backwards and forward</h2><p>You can use alt-left and alt-right to move back and forward in history of viewed pages.</p><p>This works identically to browser backwards / forwards, it's actually using built-in browser support for this.</p><p><img src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/Navigation/Note%20Navigation_image.jpg\"></p><h2>Jump to note</h2><p>This is useful to quickly find and view arbitrary notes - click on <code>Jump to</code> button on the top or press <kbd>Ctrl</kbd> + <kbd>J</kbd> . Then type part of the note name and autocomplete will help you pick the desired note.</p><p>See <a class=\"reference-link\" href=\"#root/_help_F1r9QtzQLZqm\">Jump to Note</a> for more information.</p>","_help_Ms1nauBra7gq": "<figure class=\"image image-style-align-center\"><img style=\"aspect-ratio:659/256;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/Navigation/Quick%20search_image.png\" width=\"659\" height=\"256\"></figure><p>The <em>Quick search</em> function does a full-text search (that is, it searches through the content of notes and not just the title of a note) and displays the result in an easy-to-access manner.</p><p>The alternative to the quick search is the <a class=\"reference-link\" href=\"#root/_help_eIg8jdvaoNNd\">Search</a> function, which opens in a dedicated tab and has support for advanced queries.</p><p>For even faster navigation, it's possible to use <a class=\"reference-link\" href=\"#root/_help_F1r9QtzQLZqm\">Jump to & command palette</a> which will only search through the note titles instead of the content.</p><h2>Layout</h2><p>Based on the <a class=\"reference-link\" href=\"#root/_help_x0JgW8UqGXvq\">Vertical and horizontal layout</a>, the quick search is placed:</p><ul><li>On the vertical layout, it is displayed right above the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>.</li><li>On the horizontal layout, it is displayed in the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a>, where it can be positioned just like any other icon.</li></ul><h2>Search Features</h2><p>Quick search includes the following features:</p><h3>Content Previews</h3><p>Search results now display a 200-character preview of the note content below the note title. This preview shows the context where your search terms appear, making it easier to identify the right note without opening it.</p><h3>All results in one list</h3><p>Quick search lists up to 200 matching notes in a single scrollable list, so the scrollbar shows how many results there are and how far through them you are.</p><h3>Continuing in the full search</h3><p>To refine a query with the options of the full <a class=\"reference-link\" href=\"#root/_help_eIg8jdvaoNNd\">Search</a>, click <em>Show in full search</em> below the results, or press <kbd>Ctrl</kbd>+<kbd>Enter</kbd> in the search field. The full search opens in a new tab with the same query. The button stays below the list, however far the results are scrolled.</p><h3>Visual Features</h3><ul><li><strong>Highlighting</strong>: Search terms appear in bold with accent colors</li><li><strong>Separation</strong>: Results are separated with dividers</li><li><strong>Theme Support</strong>: Highlighting colors adapt to light/dark themes</li></ul><h3>Search Behavior</h3><p>Quick search uses progressive search:</p><ol><li>Shows exact matches first</li><li>Includes fuzzy matches when exact results are fewer than 5</li><li>Exact matches appear before fuzzy matches</li></ol><h3>Search Scope</h3><p>Quick search covers only the subtree you are currently working in:</p><ul><li>Without hoisting, it covers the whole note tree.</li><li>Under a <a href=\"#root/_help_OR8WJ7Iz9K4U\">hoisted note</a> or inside a <a href=\"#root/_help_9sRHySam5fXb\">workspace</a>, it covers only that subtree.</li><li>Notes that exist only in the hidden tree, such as the built-in help pages and the launch bar configuration, are not returned. Hoist into the help to search it, or use <a href=\"#root/_help_F1r9QtzQLZqm\">Jump to…</a>, which searches titles across the hidden tree.</li></ul><p>To search the whole database while hoisted, use the full <a class=\"reference-link\" href=\"#root/_help_eIg8jdvaoNNd\">Search</a> and leave <em>Ancestor</em> field empty.</p><h3>Keyboard Navigation</h3><ul><li>Press <kbd>Enter</kbd> in the search field to search, or to refresh the results already shown.</li><li>Press <kbd>Down</kbd> in the search field to move to the first result, then <kbd>Up</kbd> and <kbd>Down</kbd> to move between results. <kbd>Up</kbd> on the first result returns to the search field.</li><li>Press <kbd>Page Down</kbd> and <kbd>Page Up</kbd> to move through the results a page at a time.</li><li>Press <kbd>Enter</kbd> on a result to open it.</li><li>Press <kbd>Ctrl</kbd>+<kbd>Enter</kbd> to open the query in the full search.</li><li>Press <kbd>Escape</kbd> to close the results.</li></ul><p>To see these shortcuts on screen, click the <kbd>?</kbd> button below the results, or press <kbd>Alt</kbd>+<kbd>F1</kbd> while the search field is focused.</p><h2>Using Quick Search</h2><ol><li><strong>Typo tolerance</strong>: Search finds results despite minor typos</li><li><strong>Content previews</strong>: 200-character snippets show match context</li><li><strong>Specific terms</strong>: Specific search terms return more focused results</li><li><strong>Match locations</strong>: Bold text indicates where matches occur</li></ol><h2>Quick Search - Exact Match Operator</h2><p>Quick Search shares the same search engine as the full <a class=\"reference-link\" href=\"#root/_help_eIg8jdvaoNNd\">Search</a>, so the exact match operator (<code>=</code>) behaves identically in both. Start your query with <code>=</code> (no space after it) to switch from the default \"contains\" behavior to exact whole-word or phrase matching.</p><p><strong>What</strong> <code>**=**</code> <strong>actually does:</strong> it finds notes where the title or content contains your term as a <strong>whole word or phrase</strong>, ignoring surrounding punctuation. It does <strong>not</strong> require the whole note to equal your term, and it does <strong>not</strong> do substring or fuzzy matching.</p><figure class=\"table\"><table><thead><tr><th>Query</th><th>Example note content</th><th>Matches?</th><th>Why</th></tr></thead><tbody><tr><td><code>sync</code></td><td><code>synchronize the database now</code></td><td>Yes</td><td>default search matches the substring</td></tr><tr><td><code>=sync</code></td><td><code>see (sync) mode</code></td><td>Yes</td><td><code>=</code> matches the whole word <code>sync</code>, punctuation ignored</td></tr><tr><td><code>=sync</code></td><td><code>synchronize the database now</code></td><td>No</td><td><code>=</code> never matches substrings</td></tr><tr><td><code>=\"project plan\"</code></td><td><code>the (project plan) is ready to share</code></td><td>Yes</td><td>quote a multi-word phrase to match it exactly</td></tr></tbody></table></figure><p>The search is case- and diacritic-insensitive. For the complete explanation of the three matching modes, fuzzy operators and relevance ranking, see <a href=\"#root/_help_eIg8jdvaoNNd\">How search matches your text</a> in the full Search documentation.</p><h3>Limitations</h3><ul><li>The <code>=</code> operator must be at the very beginning of the search query.</li><li>A space immediately after <code>=</code> is treated as a regular search.</li><li>Multiple <code>=</code> operators (like <code>==example</code>) are treated as regular text search.</li></ul><h3>Related Features</h3><ul><li>For attribute, property, boolean and ordering queries, use the full <a href=\"#root/_help_eIg8jdvaoNNd\">Search</a> functionality.</li><li>For fuzzy matching (finding results despite typos), use the <code>~=</code> or <code>~*</code> operators in the full search.</li><li>For partial matches with wildcards, use operators like <code>*=*</code>, <code>=*</code>, or <code>*=</code> in the full search.</li></ul>","_help_F1r9QtzQLZqm": "<figure class=\"image image-style-align-center\"><img style=\"aspect-ratio:991/403;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/Navigation/1_Jump%20to%20%26%20command%20palette_image.png\" width=\"991\" height=\"403\"></figure><h2>Jump to Note</h2><p>The <em>Jump to Note</em> function allows easy navigation between notes by searching for their title. In addition to that, it can also trigger a full search or create notes.</p><p>To enter the “Jump to” dialog:</p><ul><li>In the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a>, press <span class=\"tn-icon bx bx-send\"></span> button.</li><li>Using the keyboard, press <kbd>Ctrl</kbd> + <kbd>J</kbd>.</li></ul><p>In addition to searching for notes, it is also possible to search for commands. See the dedicated section below for more information.</p><h3>Interaction</h3><ul><li>By default, when there is no text entered it will display the most recent notes.</li><li>Using the keyboard, use the up or down arrow keys to navigate between items. Press <kbd>Enter</kbd> to open the desired note.</li><li>If the note doesn't exist, it's possible to create it by typing the desired note title and selecting one of two options:<ul><li><em>Create note</em> places it in the <a class=\"reference-link\" href=\"#root/_help_S0Fos78ZfcY7\">Note Inbox</a>: the note labelled <code>#inbox</code>, today's <a class=\"reference-link\" href=\"#root/_help_l0tKav7yLHGF\">Day Notes</a> if there is none, or the top level if there is no journal either. While hoisted into a <a class=\"reference-link\" href=\"#root/_help_9sRHySam5fXb\">Workspaces</a>, the workspace's own inbox is used, then today's day note if the workspace has a <code>#workspaceCalendarRoot</code>, otherwise the workspace root itself. The option names the destination, so it is always visible before the note is created.</li><li><em>Create child note</em> places it under the note that is currently open.</li></ul></li><li>When the title search does not find a note, the bar below the results offers two ways to search further. It stays below the list, however far the results are scrolled. Both are hidden while the field is empty or lists commands.<ul><li>The <em>Include note contents</em> switch searches the content of the notes as well as their titles, and lists what it finds in place of the current results, without leaving the dialog. It stays on while the query changes, until it is switched off. Press <kbd>Shift</kbd>+<kbd>Enter</kbd> to switch it from the keyboard.</li><li><em>Show in full search</em> opens the query in the full <a class=\"reference-link\" href=\"#root/_help_eIg8jdvaoNNd\">Search</a>, in a new tab, where its options can refine it. Press <kbd>Ctrl</kbd>+<kbd>Enter</kbd> to run it from the keyboard.</li></ul></li><li>To see the keys the results answer to, click the <kbd>?</kbd> button below the results, or press <kbd>Alt</kbd>+<kbd>F1</kbd> while the search field is focused.</li><li>On a wide enough desktop window, the note highlighted in the results is previewed on their right: its path, title, attributes and the start of its content. The preview follows the highlight as it moves through the results, and is left out for the command palette.</li><li>The options to create a note are listed after the notes. When no note matches, the list says so above them. <kbd>Enter</kbd> opens the note that matches best, or creates the note when none matches. Otherwise, press <kbd>↑</kbd> from the first note to reach the options to create a note.</li></ul><h2>Recent notes</h2><p>Jump to note also has the ability to show the list of recently viewed / edited notes and quickly jump to it.</p><p>To access this functionality, click on <code>Jump to</code> button on the top. By default, (when nothing is entered into autocomplete), this dialog will show the list of recent notes.</p><p>The recent notes are grouped by when they were last visited: <em>Today</em>, <em>Yesterday</em>, <em>Past 7 days</em>, <em>Past 30 days</em> and <em>Older</em>. The same list, with the same groups, opens in any note field that is focused while empty.</p><h2>Command Palette</h2><figure class=\"image image-style-align-center\"><img style=\"aspect-ratio:982/524;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/Navigation/Jump%20to%20%26%20command%20palette_image.png\" width=\"982\" height=\"524\"></figure><p>The command palette is a feature which allows easy execution of various commands that can be found throughout the application, such as from menus or keyboard shortcuts. This feature integrates directly into the “Jump to” dialog.</p><h3>Interaction</h3><p>To trigger the command palette:</p><ul><li>Press <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>J</kbd> to display the command palette directly.</li><li>If in the “Jump to” dialog, type <code>></code> in the search to switch to the command palette.</li></ul><p>Interaction:</p><ul><li>Type a few words to filter between commands.</li><li>Use the up and down arrows on the keyboard or the mouse to select a command.</li><li>Press <kbd>Enter</kbd> to execute the command.</li></ul><p>To exit the command palette:</p><ul><li>Remove the <code>></code> in the search to go back to the note search.</li><li>Press <kbd>Esc</kbd> to dismiss the dialog entirely.</li></ul><h3>Options available</h3><p>Currently the following options are displayed:</p><ul><li>Most of the <a class=\"reference-link\" href=\"#root/_help_A9Oc6YKKc65v\">Keyboard Shortcuts</a> have an entry, with the exception of those that are too specific to be run from a dialog.</li><li>Some additional options which are not yet available as keyboard shortcuts, but can be accessed from various menus such as: exporting a note, showing attachments, searching for notes or configuring the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a>.</li></ul><h3>Limitations</h3><p>Currently it's not possible to define custom actions that are displayed in the command palette. In the future this might change by integrating the options in the launch bar, which can be customized if needed.</p>",- "_help_eIg8jdvaoNNd": "<figure class=\"image\"><img style=\"aspect-ratio:987/725;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/Navigation/Search_image.png\" width=\"987\" height=\"725\"></figure><p>Note search enables you to find notes by searching for text in the title, content, or <a href=\"#root/_help_zEY4DaJG4YT5\">attributes</a> of the notes. You also have the option to save your searches, which will create a special search note which is visible on your navigation tree and contains the search results as sub-items.</p><h2>Types of search</h2><p>There are multiple types of searches, all using the same search mechanism and query language:</p><ul><li><a class=\"reference-link\" href=\"#root/_help_Ms1nauBra7gq\">Quick search</a> which can be found in the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a> for small one-off searches.<ul><li>The results are shown in a popup and it has an infinite scroll.</li></ul></li><li><em>Full search</em> is the more advanced search mechanism.<ul><li>The results are displayed in a separate page and it has multiple advanced features (search script, fast search, include archived notes, order by, limit).</li><li><a class=\"reference-link\" href=\"#root/_help_ivYnonVFBxbQ\">Bulk Actions</a> such as adding a label/relation can be applied to the results.</li><li>The results are paginated and they can be displayed in any <a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a> view (e.g. grid, list, calendar, table).</li></ul></li><li>Some <a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a> such as board view have a dedicated search bar which applies to that collection.<ul><li>In this case, the results are displayed directly in the collection instead of a popup and they are limited to the collection but the query language remains the same.</li></ul></li></ul><aside class=\"admonition note\"><p><a href=\"#root/_help_F1r9QtzQLZqm\">Jump to note</a> is a similar concept but it's mainly used to search for notes by title, not by content. Nevertheless, it also features a way to search in full text if the results are unsatisfactory.</p></aside><h2>Accessing the search</h2><ul><li>From the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a>, look for the dedicated <span class=\"tn-icon bx bx-search\"></span> search button.</li><li>To limit the search to a note and its children, select <em>Search in subtree</em> (<span class=\"tn-icon bx bx-search\"></span>) from the <a class=\"reference-link\" href=\"#root/_help_YtSN43OrfzaA\">Note tree contextual menu</a> or press <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>S</kbd>.</li><li>Go to <a class=\"reference-link\" href=\"#root/_help_F1r9QtzQLZqm\">Jump to & command palette</a>, look for something then press <em>Show in full search</em> below the results (or <kbd>Ctrl</kbd>+<kbd>Enter</kbd>).</li></ul><h2>Interaction</h2><p>To search for notes, click on the <span class=\"tn-icon bx bx-search\"></span> icon in the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a> or press the keyboard <a href=\"#root/_help_A9Oc6YKKc65v\">shortcut</a>.</p><ol><li>Set the text to search for in the <em>Search string</em> field.<ol><li>Apart from searching for words literally, there is also the possibility to search for attributes or properties of notes.</li><li>See the examples below for more information.</li></ol></li><li>To limit the search to a note and its sub-children, set a note in <em>Ancestor</em>.<ol><li>This value is also pre-filled if the search is triggered from a <a href=\"#root/_help_OR8WJ7Iz9K4U\">hoisted note</a> or a <a href=\"#root/_help_9sRHySam5fXb\">workspace</a>.</li><li>To search the entire database, keep the value empty.</li></ol></li><li>To limit the search to only a few levels of hierarchy (e.g. look in sub-children but not in sub-sub-children of a note), set the <em>depth</em> field to one of the provided values.</li><li>In addition to that, the search can be configured via the <em>Add search option</em> menu, as described in the follow-up section.</li><li>Press <em>Search</em> (<span class=\"tn-icon bx bx-search\"></span>) to trigger the search. The results are displayed below the search configuration pane.</li><li>The <em>Search & Execute actions</em> (<span class=\"tn-icon bx bxs-zap\"></span>) entry in the menu beside <em>Search</em> is only relevant if at least one action has been added (as described in the section below).</li><li>The <em>Save to note</em> (<span class=\"tn-icon bx bx-save\"></span>) entry in the same menu will create a new note with the search configuration. For more information, see <a class=\"reference-link\" href=\"#root/_help_m523cpzocqaD\">Saved Search</a>.</li></ol><h2>Features</h2><h3>Autocomplete</h3><p>To help with the syntax, Trilium offers an autocomplete functionality which can be triggered by pressing <kbd>Ctrl</kbd>+<kbd>Space</kbd>.</p><p>Some suggestions also open on their own as you type: label and relation names after <code>#</code> and <code>~</code>, fields after <code>.</code>, operators, values, and notes after <code>@</code>. Keywords such as <code>and</code>, <code>or</code>, <code>not</code>, <code>orderBy</code> and <code>limit</code> appear only on <kbd>Ctrl</kbd>+<kbd>Space</kbd>, since a plain word is usually a search term.</p><p>No suggestion is selected when a list opens on its own, so <kbd>Enter</kbd> runs the search as typed. To insert a suggestion, select it with <kbd>Down</kbd> and press <kbd>Enter</kbd>. The list opened with <kbd>Ctrl</kbd>+<kbd>Space</kbd> and the notes after <code>@</code> open on the best match instead, so <kbd>Enter</kbd> inserts it.</p><p>The autocomplete offers:</p><ul><li>Basic operators such as <code>*=</code> and keywords (<code>limit</code>, <code>not</code>).</li><li>Fields for object-like fields such as <code>note</code> or <code>~relation</code>, triggered by typing <code>.</code>.</li><li>Contextual enumerations such as <code>note.type = \"</code> or <code>note.mime = \"</code>.</li><li><a href=\"#root/_help_HI6GBBIduIgv\">Label</a> names by typing <code>#</code>.<ul><li>A small gear on the name's icon indicates a system attribute.</li><li>After typing the label name, the value is also autocompleted with values that are present in the database.</li></ul></li><li><a href=\"#root/_help_Cq5X6iKQop6R\">Relation</a> names by typing <code>~</code>.</li><li><a href=\"#root/_help_m1lbrzyKDaRB\">Note ID</a>s can be inserted easily by typing <code>@</code> and looking for a note.<ul><li>If the note ID is under a valid syntax, it will be shown as a chip of the note instead of the raw ID.</li><li>This is especially useful for queries that make use of the note ID such as searching by template: <code>~template.noteId = @</code></li></ul></li></ul><h3>Syntax highlighting</h3><p>The search input features syntax highlighting, making recognized fields such as <code>note.</code> and operators like <code>NOT</code> stand out.</p><h3>Error highlighting & linting</h3><p>The search is also checked for errors in two phases, which will be displayed as a red squiggle:</p><ul><li>Linter errors which identify common error patterns and also provide a way to fix them.</li><li>Search errors which are checked by the server, without indicating the exact place the error occurred.</li></ul><p>An error the search only runs into while running, such as an operator that note content cannot be searched with, is shown in a <em>Search error</em> card instead: below the search string, or at the top of the <a class=\"reference-link\" href=\"#root/_help_Ms1nauBra7gq\">Quick search</a> results.</p><h3>Multiline</h3><p>Long or complicated searches can be formatted by using newlines, similar to SQL queries. Newlines are treated just like spaces.</p><p>To add a new line, press <kbd>Shift</kbd>+<kbd>Enter</kbd>.</p><aside class=\"admonition note\"><p>Multiline is available only for the full search, other inputs such as the quick search or the collection filter are single line.</p></aside><h2>Search options</h2><p>Click <em>Add search option</em> to choose an option to apply.</p><ul><li>For each search option selected, the search configuration will update to reveal the entry. Each search option will have its own configuration.</li><li>To remove a search option, simply press the <span class=\"tn-icon bx bx-x\"></span> button to the right of it.</li></ul><p>The options available are:</p><ol><li><span class=\"tn-icon bx bx-code\"></span> Search script<ol><li>This feature allows writing a <a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a> note that will handle the search on its own.</li></ol></li><li><span class=\"tn-icon bx bx-run\"></span> Fast search<ol><li>The search will not look into the content of the notes, but it will still look into note titles and attributes, relations (based on the search query).</li><li>This method can speed up the search considerably for large <a href=\"#root/_help_wX4HbRucYSDD\">databases</a>.</li></ol></li><li><span class=\"tn-icon bx bx-archive\"></span> Include archived<ol><li><a class=\"reference-link\" href=\"#root/_help_MKmLg5x6xkor\">Archived Notes</a> will also be included in the results, whereas otherwise they would be ignored.</li></ol></li><li><span class=\"tn-icon bx bx-arrow-from-top\"></span> Order by<ol><li>Allows changing the criteria for ordering the results, for example to order by creation date or alphabetically instead of by relevancy (default).</li><li>It's also possible to change the order (ascending or descending) of the results.</li></ol></li><li><span class=\"tn-icon bx bx-stop\"></span> Limit<ol><li>Limits the results to a given maximum.</li><li>This can help if the number of results would otherwise be high, at the cost of not being able to view all the results.</li></ol></li><li><span class=\"tn-icon bx bx-bug\"></span> Debug<ol><li>This will print additional information in the server log (see <a class=\"reference-link\" href=\"#root/_help_qzNzp9LYQyPT\">Error logs</a>), regarding how the search expression was parsed.</li><li>This function is especially useful after understanding the search functionality in detail, in order to determine why a complex search query is not working as expected.</li></ol></li></ol><p>The same menu ends with a <em>Bulk actions</em> section for applying changes such as adding a label or a relation to the matched notes. Its groups—<em>Labels</em>, <em>Relations</em>, <em>Notes</em> and <em>Other</em>—each open a list of the actions in the corresponding group of the <a class=\"reference-link\" href=\"#root/_help_ivYnonVFBxbQ\">Bulk Actions</a> dialog, which is an alternative for operating directly with notes within the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>. Choosing one adds it to the search; unlike the other options, the same action can be added more than once (e.g. to apply multiple labels). After defining the actions, first press <em>Search</em> to check the matched notes and then choose <em>Search & Execute actions</em> from the menu beside it to trigger the actions.</p><h2>Viewing search results</h2><p>Results appear below the search pane, by default in the <em>Search preview</em> view. Each result is drawn as a <strong>snippet card</strong> with the note title, the path to it, a short excerpt of the matching text, and the attributes that matched.</p><p>To show the results as a plain note list instead, choose <em>List</em> from the <a class=\"reference-link\" href=\"#root/_help_CssoWBu8I7jF\">Collection Properties</a> bar. The <em>List</em> view shows one row per note, with the note's title and content preview.</p><p>The search will also highlight the words from the title or content that matched:</p><ul><li>With a solid underlined green for a direct match;</li><li>With a dotted underline orange for a partial match (matched by the fuzzy search).</li></ul><p>In addition, the <em>Search preview</em> view offers:</p><ul><li>The <strong>total number of results</strong> is always shown, so you can immediately tell how broad a query is.</li><li>A <strong>page-size selector</strong> lets you choose how many results to display per page. Your choice is remembered and synced across your devices (stored in the <code>searchResultsPageSize</code> option), so you do not have to reset it on every device.</li><li><strong>Clicking a result's title</strong> opens the note and jumps straight to the first match. The in-note find bar opens pre-filled with the first word of your search, so you can step through its matches with the find controls. To have the find bar look for a whole phrase instead, put the phrase in quotes in the search, e.g. <code>\"The Lord of the Rings\"</code>. In read-only notes, the other words of the search are highlighted as well. The excerpt and attributes can be selected without opening the note.</li><li><em>Open all results in new tabs</em> (<span class=\"tn-icon bx bx-window-open\"></span>, the button above the results) opens every result in a tab of its own, up to 50. Each tab opens on its first match with the find bar pre-filled, as when clicking a result.</li><li>If a match is inside a <strong>collapsed section</strong> (for example a folded heading), that section is expanded automatically so the match is visible.</li><li>When the excerpt is cut short, a <em>Show more</em> button expands the card to the note's full content, with the search terms highlighted. <em>Show less</em> returns to the excerpt.</li></ul><h2>Simple Note Search Examples</h2><ul><li><code>rings tolkien</code>: Full-text search to find notes containing both \"rings\" and \"tolkien\".</li><li><code>\"The Lord of the Rings\" Tolkien</code>: Full-text search where \"The Lord of the Rings\" must match exactly.</li><li><code>note.content *=* rings OR note.content *=* tolkien</code>: Find notes containing \"rings\" or \"tolkien\" in their content.</li><li><code>towers #book</code>: Combine full-text and attribute search to find notes containing \"towers\" and having the \"book\" label. Writing <code>towers AND #book</code> does the same; to search for the word \"and\" itself, put it in quotes.</li><li><code>c#</code> or <code>towers#book</code>: A <code>#</code> or <code>~</code> inside a word is part of the text, so these find notes containing \"c#\" or \"towers#book\". To start a label or relation, put a space before it.</li><li><code>towers #book or #author</code>: Search for notes containing \"towers\" and having either the \"book\" or \"author\" label.</li><li><code>towers #!book</code>: Search for notes containing \"towers\" and not having the \"book\" label.</li><li><code>#book #publicationYear = 1954</code>: Find notes with the \"book\" label and \"publicationYear\" set to 1954.</li><li><code>#genre *=* fan</code>: Find notes with the \"genre\" label containing the substring \"fan\". Additional operators include <code>*=*</code> for \"contains\", <code>=*</code> for \"starts with\", <code>*=</code> for \"ends with\", and <code>!=</code> for \"is not equal to\".</li><li><code>#book #publicationYear >= 1950 #publicationYear < 1960</code>: Use numeric operators to find all books published in the 1950s.</li><li><code>#dateNote >= TODAY-30</code>: Find notes with the \"dateNote\" label within the last 30 days. Supported date values include NOW +- seconds, TODAY +- days, MONTH +- months, YEAR +- years.</li><li><code>~author.title *=* Tolkien</code>: Find notes related to an author whose title contains \"Tolkien\".</li><li><code>#publicationYear %= '19[0-9]{2}'</code>: Use the '%=' operator to match a regular expression (regex). This feature has been available since Trilium 0.52.</li><li><code>note.content %= '\\\\d{2}:\\\\d{2} (PM|AM)'</code>: Find notes that mention a time. Backslashes in a regex must be escaped.</li></ul><h2>Advanced Use Cases</h2><ul><li><code>~author.relations.son.title = 'Christopher Tolkien'</code>: Search for notes with an \"author\" relation to a note that has a \"son\" relation to \"Christopher Tolkien\". This can be modeled with the following note structure:<ul><li>Books<ul><li>Lord of the Rings<ul><li>label: “book”</li><li>relation: “author” points to “J. R. R. Tolkien” note</li></ul></li></ul></li><li>People<ul><li>J. R. R. Tolkien<ul><li>relation: “son” points to \"Christopher Tolkien\" note</li><li>Christopher Tolkien</li></ul></li></ul></li></ul></li><li><code>~author.title *= Tolkien OR (#publicationDate >= 1954 AND #publicationDate <= 1960)</code>: Use boolean expressions and parentheses to group expressions.</li><li><code>towers (#genre = fantasy OR #genre = scifi)</code>: A group can open the expression part directly, without a <code>#</code> or <code>~</code> before the parenthesis. Here it finds notes containing \"towers\" whose genre is fantasy or scifi.</li><li><code>note.parents.title = 'Books'</code>: Find notes with a parent named \"Books\".</li><li><code>note.parents.parents.title = 'Books'</code>: Find notes with a grandparent named \"Books\".</li><li><code>note.ancestors.title = 'Books'</code>: Find notes with an ancestor named \"Books\".</li><li><code>note.children.title = 'sub-note'</code>: Find notes with a child named \"sub-note\".</li><li><code>note.links.title = 'Tolkien'</code>: Find notes linking to a note named \"Tolkien\".</li><li><code>note.backlinks.title = 'Reading list'</code>: Find the notes that \"Reading list\" links to.</li><li>A link is a relation you created, such as <code>~author</code>, or one that content creates: an internal link (<code>~internalLink</code>), an image (<code>~imageLink</code>), an included note (<code>~includeNoteLink</code>) or a relation map connection (<code>~relationMapLink</code>). Relations that configure a note, such as <code>~template</code> or a saved search's <code>~ancestor</code>, are not links.</li></ul><p>See also <a class=\"reference-link\" href=\"#root/_help_Oxyb6jOjjVNL\">Under the hood</a> for more syntax references.</p><h3>Search with Note Properties</h3><p>Notes have properties that can be used in searches, such as <code>noteId</code>, <code>dateModified</code>, <code>dateCreated</code>, <code>isProtected</code>, <code>type</code>, <code>title</code>, <code>text</code>, <code>content</code>, <code>rawContent</code>, <code>ownedLabelCount</code>, <code>labelCount</code>, <code>ownedRelationCount</code>, <code>relationCount</code>, <code>ownedRelationCountIncludingLinks</code>, <code>relationCountIncludingLinks</code>, <code>ownedAttributeCount</code>, <code>attributeCount</code>, <code>targetRelationCount</code>, <code>targetRelationCountIncludingLinks</code>, <code>parentCount</code>, <code>childrenCount</code>, <code>isArchived</code>, <code>contentSize</code>, <code>noteSize</code>, and <code>revisionCount</code>.</p><p>These properties can be accessed via the <code>note.</code> prefix, e.g., <code>note.type = code AND note.mime = 'application/json'</code>.</p><h3>Order by and Limit</h3><pre><code class=\"language-text-x-trilium-auto\">#author=Tolkien orderBy #publicationDate desc, note.title limit 10</code></pre><p>This example will:</p><ol><li>Find notes with the author label \"Tolkien\".</li><li>Order the results by <code>publicationDate</code> in descending order.</li><li>Use <code>note.title</code> as a secondary ordering if publication dates are equal.</li><li>Limit the results to the first 10 notes.</li></ol><h3>Negation</h3><p>Some queries can only be expressed with negation:</p><pre><code class=\"language-text-x-trilium-auto\">#book AND not(note.ancestors.title = 'Tolkien')</code></pre><p>This query finds all book notes not in the \"Tolkien\" subtree.</p><h2>Under the Hood</h2><p>See the <a href=\"#root/_help_Oxyb6jOjjVNL\">dedicated page</a> to understand how progressive search works in Trilium, as well as some advanced use cases.</p><h2>Auto-Trigger Search from URL</h2><p>You can open Trilium and automatically trigger a search by including the search <a href=\"https://meyerweb.com/eric/tools/dencoder/\">url encoded</a> string in the URL:</p><p><code>http://localhost:8080/#?searchString=abc</code></p><h2>Search Configuration</h2><h3>Parameters</h3><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Value</th><th>Description</th></tr></thead><tbody><tr><td><code>MIN_FUZZY_TOKEN_LENGTH</code></td><td>3</td><td>Minimum characters the <code>~=</code> and <code>~*</code> operators accept</td></tr><tr><td><code>MAX_EDIT_DISTANCE</code></td><td>2</td><td>Ceiling on character changes, reached only by 7+ character terms; shorter terms allow fewer. See the <em>Fuzzy tolerance</em> section above</td></tr><tr><td><code>RESULT_SUFFICIENCY_THRESHOLD</code></td><td>5</td><td>Minimum exact results before fuzzy fallback</td></tr><tr><td><code>MAX_CONTENT_SIZE</code></td><td>10MB</td><td>Maximum note content size for search processing</td></tr></tbody></table></figure><h3>Limits</h3><ul><li>Searched note content is limited to 10MB per note to prevent performance issues</li><li>Notes exceeding this limit will still be included in title and attribute searches</li><li>Terms of 3 characters or fewer are matched exactly; typo tolerance starts at 4 characters</li></ul>",+ "_help_eIg8jdvaoNNd": "<figure class=\"image\"><img style=\"aspect-ratio:987/725;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/Navigation/Search_image.png\" width=\"987\" height=\"725\"></figure><p>Note search enables you to find notes by searching for text in the title, content, or <a href=\"#root/_help_zEY4DaJG4YT5\">attributes</a> of the notes. You also have the option to save your searches, which will create a special search note which is visible on your navigation tree and contains the search results as sub-items.</p><h2>Types of search</h2><p>There are multiple types of searches, all using the same search mechanism and query language:</p><ul><li><a class=\"reference-link\" href=\"#root/_help_Ms1nauBra7gq\">Quick search</a> which can be found in the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a> for small one-off searches.<ul><li>The results are shown in a popup and it has an infinite scroll.</li></ul></li><li><em>Full search</em> is the more advanced search mechanism.<ul><li>The results are displayed in a separate page and it has multiple advanced features (search script, fast search, include archived notes, order by, limit).</li><li><a class=\"reference-link\" href=\"#root/_help_ivYnonVFBxbQ\">Bulk Actions</a> such as adding a label/relation can be applied to the results.</li><li>The results are paginated and they can be displayed in any <a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a> view (e.g. grid, list, calendar, table).</li></ul></li><li>Some <a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a> such as board view have a dedicated search bar which applies to that collection.<ul><li>In this case, the results are displayed directly in the collection instead of a popup and they are limited to the collection but the query language remains the same.</li></ul></li></ul><aside class=\"admonition note\"><p><a href=\"#root/_help_F1r9QtzQLZqm\">Jump to note</a> is a similar concept but it's mainly used to search for notes by title, not by content. Nevertheless, it also features a way to search in full text if the results are unsatisfactory.</p></aside><h2>Accessing the search</h2><ul><li>From the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a>, look for the dedicated <span class=\"tn-icon bx bx-search\"></span> search button.</li><li>To limit the search to a note and its children, select <em>Search in subtree</em> (<span class=\"tn-icon bx bx-search\"></span>) from the <a class=\"reference-link\" href=\"#root/_help_YtSN43OrfzaA\">Note tree contextual menu</a> or press <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>S</kbd>.</li><li>Go to <a class=\"reference-link\" href=\"#root/_help_F1r9QtzQLZqm\">Jump to & command palette</a>, look for something then press <em>Show in full search</em> below the results (or <kbd>Ctrl</kbd>+<kbd>Enter</kbd>).</li></ul><h2>Interaction</h2><p>To search for notes, click on the <span class=\"tn-icon bx bx-search\"></span> icon in the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a> or press the keyboard <a href=\"#root/_help_A9Oc6YKKc65v\">shortcut</a>.</p><ol><li>Set the text to search for in the <em>Search string</em> field.<ol><li>Apart from searching for words literally, there is also the possibility to search for attributes or properties of notes.</li><li>See the examples below for more information.</li></ol></li><li>To limit the search to a note and its sub-children, set a note in <em>Ancestor</em>.<ol><li>This value is also pre-filled if the search is triggered from a <a href=\"#root/_help_OR8WJ7Iz9K4U\">hoisted note</a> or a <a href=\"#root/_help_9sRHySam5fXb\">workspace</a>.</li><li>To search the entire database, keep the value empty.</li></ol></li><li>To limit the search to only a few levels of hierarchy (e.g. look in sub-children but not in sub-sub-children of a note), set the <em>depth</em> field to one of the provided values.</li><li>In addition to that, the search can be configured via the <em>Add search option</em> menu, as described in the follow-up section.</li><li>Press <em>Search</em> (<span class=\"tn-icon bx bx-search\"></span>) to trigger the search. The results are displayed below the search configuration pane.</li><li>The <em>Search & Execute actions</em> (<span class=\"tn-icon bx bxs-zap\"></span>) entry in the menu beside <em>Search</em> is only relevant if at least one action has been added (as described in the section below).</li><li>The <em>Save to note</em> (<span class=\"tn-icon bx bx-save\"></span>) entry in the same menu will create a new note with the search configuration. For more information, see <a class=\"reference-link\" href=\"#root/_help_m523cpzocqaD\">Saved Search</a>.</li></ol><h2>Features</h2><h3>Autocomplete</h3><p>To help with the syntax, Trilium offers an autocomplete functionality which can be triggered by pressing <kbd>Ctrl</kbd>+<kbd>Space</kbd>.</p><p>Some suggestions also open on their own as you type: label and relation names after <code>#</code> and <code>~</code>, fields after <code>.</code>, operators, values, and notes after <code>@</code>. Keywords such as <code>and</code>, <code>or</code>, <code>not</code>, <code>orderBy</code> and <code>limit</code> appear only on <kbd>Ctrl</kbd>+<kbd>Space</kbd>, since a plain word is usually a search term.</p><p>No suggestion is selected when a list opens on its own, so <kbd>Enter</kbd> runs the search as typed. To insert a suggestion, select it with <kbd>Down</kbd> and press <kbd>Enter</kbd>. The list opened with <kbd>Ctrl</kbd>+<kbd>Space</kbd> and the notes after <code>@</code> open on the best match instead, so <kbd>Enter</kbd> inserts it.</p><p>The autocomplete offers:</p><ul><li>Basic operators such as <code>*=</code> and keywords (<code>limit</code>, <code>not</code>).</li><li>Fields for object-like fields such as <code>note</code> or <code>~relation</code>, triggered by typing <code>.</code>.</li><li>Contextual enumerations such as <code>note.type = \"</code> or <code>note.mime = \"</code>.</li><li><a href=\"#root/_help_HI6GBBIduIgv\">Label</a> names by typing <code>#</code>.<ul><li>A small gear on the name's icon indicates a system attribute.</li><li>After typing the label name, the value is also autocompleted with values that are present in the database.</li></ul></li><li><a href=\"#root/_help_Cq5X6iKQop6R\">Relation</a> names by typing <code>~</code>.</li><li><a href=\"#root/_help_m1lbrzyKDaRB\">Note ID</a>s can be inserted easily by typing <code>@</code> and looking for a note.<ul><li>If the note ID is under a valid syntax, it will be shown as a chip of the note instead of the raw ID.</li><li>This is especially useful for queries that make use of the note ID such as searching by template: <code>~template.noteId = @</code></li></ul></li></ul><h3>Syntax highlighting</h3><p>The search input features syntax highlighting, making recognized fields such as <code>note.</code> and operators like <code>NOT</code> stand out.</p><h3>Error highlighting & linting</h3><p>The search is also checked for errors in two phases, which will be displayed as a red squiggle:</p><ul><li>Linter errors which identify common error patterns and also provide a way to fix them.</li><li>Search errors which are checked by the server, without indicating the exact place the error occurred.</li></ul><p>An error the search only runs into while running, such as an operator that note content cannot be searched with, is shown in a <em>Search error</em> card instead: below the search string, or at the top of the <a class=\"reference-link\" href=\"#root/_help_Ms1nauBra7gq\">Quick search</a> results.</p><h3>Multiline</h3><p>Long or complicated searches can be formatted by using newlines, similar to SQL queries. Newlines are treated just like spaces.</p><p>To add a new line, press <kbd>Shift</kbd>+<kbd>Enter</kbd>.</p><aside class=\"admonition note\"><p>Multiline is available only for the full search, other inputs such as the quick search or the collection filter are single line.</p></aside><h2>Search options</h2><p>Click <em>Add search option</em> to choose an option to apply.</p><ul><li>For each search option selected, the search configuration will update to reveal the entry. Each search option will have its own configuration.</li><li>To remove a search option, simply press the <span class=\"tn-icon bx bx-x\"></span> button to the right of it.</li></ul><p>The options available are:</p><ol><li><span class=\"tn-icon bx bx-code\"></span> Search script<ol><li>This feature allows writing a <a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a> note that will handle the search on its own.</li></ol></li><li><span class=\"tn-icon bx bx-run\"></span> Fast search<ol><li>The search will not look into the content of the notes, but it will still look into note titles and attributes, relations (based on the search query).</li><li>This method can speed up the search considerably for large <a href=\"#root/_help_wX4HbRucYSDD\">databases</a>.</li></ol></li><li><span class=\"tn-icon bx bx-archive\"></span> Include archived<ol><li><a class=\"reference-link\" href=\"#root/_help_MKmLg5x6xkor\">Archived Notes</a> will also be included in the results, whereas otherwise they would be ignored.</li></ol></li><li><span class=\"tn-icon bx bx-arrow-from-top\"></span> Order by<ol><li>Allows changing the criteria for ordering the results, for example to order by creation date or alphabetically instead of by relevancy (default).</li><li>It's also possible to change the order (ascending or descending) of the results.</li></ol></li><li><span class=\"tn-icon bx bx-stop\"></span> Limit<ol><li>Limits the results to a given maximum.</li><li>This can help if the number of results would otherwise be high, at the cost of not being able to view all the results.</li></ol></li><li><span class=\"tn-icon bx bx-bug\"></span> Debug<ol><li>This will print additional information in the server log (see <a class=\"reference-link\" href=\"#root/_help_qzNzp9LYQyPT\">Error logs</a>), regarding how the search expression was parsed.</li><li>This function is especially useful after understanding the search functionality in detail, in order to determine why a complex search query is not working as expected.</li></ol></li></ol><p>The same menu ends with a <em>Bulk actions</em> section for applying changes such as adding a label or a relation to the matched notes. Its groups—<em>Labels</em>, <em>Relations</em>, <em>Notes</em> and <em>Other</em>—each open a list of the actions in the corresponding group of the <a class=\"reference-link\" href=\"#root/_help_ivYnonVFBxbQ\">Bulk Actions</a> dialog, which is an alternative for operating directly with notes within the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>. Choosing one adds it to the search; unlike the other options, the same action can be added more than once (e.g. to apply multiple labels). After defining the actions, first press <em>Search</em> to check the matched notes and then choose <em>Search & Execute actions</em> from the menu beside it to trigger the actions.</p><h2>Viewing search results</h2><p>Results appear below the search pane, by default in the <em>Search preview</em> view. Each result is drawn as a <strong>snippet card</strong> with the note title, the path to it, a short excerpt of the matching text, and the attributes that matched. The excerpt of a code note keeps its indentation and is shown in the code font.</p><p>To show the results as a plain note list instead, choose <em>List</em> from the <a class=\"reference-link\" href=\"#root/_help_CssoWBu8I7jF\">Collection Properties</a> bar. The <em>List</em> view shows one row per note, with the note's title and content preview.</p><p>The search will also highlight the words from the title or content that matched:</p><ul><li>With a solid underlined green for a direct match;</li><li>With a dotted underline orange for a partial match (matched by the fuzzy search).</li></ul><p>In addition, the <em>Search preview</em> view offers:</p><ul><li>The <strong>total number of results</strong> is always shown, so you can immediately tell how broad a query is.</li><li>A <strong>page-size selector</strong> lets you choose how many results to display per page. Your choice is remembered and synced across your devices (stored in the <code>searchResultsPageSize</code> option), so you do not have to reset it on every device.</li><li><strong>Clicking a result's title</strong> opens the note and jumps straight to the first match. The in-note find bar opens pre-filled with the first word of your search, so you can step through its matches with the find controls. To have the find bar look for a whole phrase instead, put the phrase in quotes in the search, e.g. <code>\"The Lord of the Rings\"</code>. In read-only notes, the other words of the search are highlighted as well. The excerpt and attributes can be selected without opening the note.</li><li><em>Open all results in new tabs</em> (<span class=\"tn-icon bx bx-window-open\"></span>, the button above the results) opens every result in a tab of its own, up to 50. Each tab opens on its first match with the find bar pre-filled, as when clicking a result.</li><li>If a match is inside a <strong>collapsed section</strong> (for example a folded heading), that section is expanded automatically so the match is visible.</li><li>When the excerpt is cut short, a <em>Show more</em> button expands the card to the note's full content, with the search terms highlighted. <em>Show less</em> returns to the excerpt.</li></ul><h2>Simple Note Search Examples</h2><ul><li><code>rings tolkien</code>: Full-text search to find notes containing both \"rings\" and \"tolkien\".</li><li><code>\"The Lord of the Rings\" Tolkien</code>: Full-text search where \"The Lord of the Rings\" must match exactly.</li><li><code>note.content *=* rings OR note.content *=* tolkien</code>: Find notes containing \"rings\" or \"tolkien\" in their content.</li><li><code>towers #book</code>: Combine full-text and attribute search to find notes containing \"towers\" and having the \"book\" label. Writing <code>towers AND #book</code> does the same; to search for the word \"and\" itself, put it in quotes.</li><li><code>c#</code> or <code>towers#book</code>: A <code>#</code> or <code>~</code> inside a word is part of the text, so these find notes containing \"c#\" or \"towers#book\". To start a label or relation, put a space before it.</li><li><code>towers #book or #author</code>: Search for notes containing \"towers\" and having either the \"book\" or \"author\" label.</li><li><code>towers #!book</code>: Search for notes containing \"towers\" and not having the \"book\" label.</li><li><code>#book #publicationYear = 1954</code>: Find notes with the \"book\" label and \"publicationYear\" set to 1954.</li><li><code>#genre *=* fan</code>: Find notes with the \"genre\" label containing the substring \"fan\". Additional operators include <code>*=*</code> for \"contains\", <code>=*</code> for \"starts with\", <code>*=</code> for \"ends with\", and <code>!=</code> for \"is not equal to\".</li><li><code>#book #publicationYear >= 1950 #publicationYear < 1960</code>: Use numeric operators to find all books published in the 1950s.</li><li><code>#dateNote >= TODAY-30</code>: Find notes with the \"dateNote\" label within the last 30 days. Supported date values include NOW +- seconds, TODAY +- days, MONTH +- months, YEAR +- years.</li><li><code>~author.title *=* Tolkien</code>: Find notes related to an author whose title contains \"Tolkien\".</li><li><code>#publicationYear %= '19[0-9]{2}'</code>: Use the '%=' operator to match a regular expression (regex). This feature has been available since Trilium 0.52.</li><li><code>note.content %= '\\\\d{2}:\\\\d{2} (PM|AM)'</code>: Find notes that mention a time. Backslashes in a regex must be escaped.</li></ul><h2>Advanced Use Cases</h2><ul><li><code>~author.relations.son.title = 'Christopher Tolkien'</code>: Search for notes with an \"author\" relation to a note that has a \"son\" relation to \"Christopher Tolkien\". This can be modeled with the following note structure:<ul><li>Books<ul><li>Lord of the Rings<ul><li>label: “book”</li><li>relation: “author” points to “J. R. R. Tolkien” note</li></ul></li></ul></li><li>People<ul><li>J. R. R. Tolkien<ul><li>relation: “son” points to \"Christopher Tolkien\" note</li><li>Christopher Tolkien</li></ul></li></ul></li></ul></li><li><code>~author.title *= Tolkien OR (#publicationDate >= 1954 AND #publicationDate <= 1960)</code>: Use boolean expressions and parentheses to group expressions.</li><li><code>towers (#genre = fantasy OR #genre = scifi)</code>: A group can open the expression part directly, without a <code>#</code> or <code>~</code> before the parenthesis. Here it finds notes containing \"towers\" whose genre is fantasy or scifi.</li><li><code>note.parents.title = 'Books'</code>: Find notes with a parent named \"Books\".</li><li><code>note.parents.parents.title = 'Books'</code>: Find notes with a grandparent named \"Books\".</li><li><code>note.ancestors.title = 'Books'</code>: Find notes with an ancestor named \"Books\".</li><li><code>note.children.title = 'sub-note'</code>: Find notes with a child named \"sub-note\".</li><li><code>note.links.title = 'Tolkien'</code>: Find notes linking to a note named \"Tolkien\".</li><li><code>note.backlinks.title = 'Reading list'</code>: Find the notes that \"Reading list\" links to.</li><li>A link is a relation you created, such as <code>~author</code>, or one that content creates: an internal link (<code>~internalLink</code>), an image (<code>~imageLink</code>), an included note (<code>~includeNoteLink</code>) or a relation map connection (<code>~relationMapLink</code>). Relations that configure a note, such as <code>~template</code> or a saved search's <code>~ancestor</code>, are not links.</li></ul><p>See also <a class=\"reference-link\" href=\"#root/_help_Oxyb6jOjjVNL\">Under the hood</a> for more syntax references.</p><h3>Search with Note Properties</h3><p>Notes have properties that can be used in searches, such as <code>noteId</code>, <code>dateModified</code>, <code>dateCreated</code>, <code>isProtected</code>, <code>type</code>, <code>title</code>, <code>text</code>, <code>content</code>, <code>rawContent</code>, <code>ownedLabelCount</code>, <code>labelCount</code>, <code>ownedRelationCount</code>, <code>relationCount</code>, <code>ownedRelationCountIncludingLinks</code>, <code>relationCountIncludingLinks</code>, <code>ownedAttributeCount</code>, <code>attributeCount</code>, <code>targetRelationCount</code>, <code>targetRelationCountIncludingLinks</code>, <code>parentCount</code>, <code>childrenCount</code>, <code>isArchived</code>, <code>contentSize</code>, <code>noteSize</code>, and <code>revisionCount</code>.</p><p>These properties can be accessed via the <code>note.</code> prefix, e.g., <code>note.type = code AND note.mime = 'application/json'</code>.</p><h3>Order by and Limit</h3><pre><code class=\"language-text-x-trilium-auto\">#author=Tolkien orderBy #publicationDate desc, note.title limit 10</code></pre><p>This example will:</p><ol><li>Find notes with the author label \"Tolkien\".</li><li>Order the results by <code>publicationDate</code> in descending order.</li><li>Use <code>note.title</code> as a secondary ordering if publication dates are equal.</li><li>Limit the results to the first 10 notes.</li></ol><h3>Negation</h3><p>Some queries can only be expressed with negation:</p><pre><code class=\"language-text-x-trilium-auto\">#book AND not(note.ancestors.title = 'Tolkien')</code></pre><p>This query finds all book notes not in the \"Tolkien\" subtree.</p><h2>Under the Hood</h2><p>See the <a href=\"#root/_help_Oxyb6jOjjVNL\">dedicated page</a> to understand how progressive search works in Trilium, as well as some advanced use cases.</p><h2>Auto-Trigger Search from URL</h2><p>You can open Trilium and automatically trigger a search by including the search <a href=\"https://meyerweb.com/eric/tools/dencoder/\">url encoded</a> string in the URL:</p><p><code>http://localhost:8080/#?searchString=abc</code></p><h2>Search Configuration</h2><h3>Parameters</h3><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Value</th><th>Description</th></tr></thead><tbody><tr><td><code>MIN_FUZZY_TOKEN_LENGTH</code></td><td>3</td><td>Minimum characters the <code>~=</code> and <code>~*</code> operators accept</td></tr><tr><td><code>MAX_EDIT_DISTANCE</code></td><td>2</td><td>Ceiling on character changes, reached only by 7+ character terms; shorter terms allow fewer. See the <em>Fuzzy tolerance</em> section above</td></tr><tr><td><code>RESULT_SUFFICIENCY_THRESHOLD</code></td><td>5</td><td>Minimum exact results before fuzzy fallback</td></tr><tr><td><code>MAX_CONTENT_SIZE</code></td><td>10MB</td><td>Maximum note content size for search processing</td></tr></tbody></table></figure><h3>Limits</h3><ul><li>Searched note content is limited to 10MB per note to prevent performance issues</li><li>Notes exceeding this limit will still be included in title and attribute searches</li><li>Terms of 3 characters or fewer are matched exactly; typo tolerance starts at 4 characters</li></ul>","_help_Oxyb6jOjjVNL": "<h2>Progressive Search Strategy</h2><p>Trilium uses a progressive search strategy that performs exact matching first, then adds fuzzy matching when needed.</p><p>The search has three phases:</p><ol><li><strong>Phase 1 - Exact Matching</strong>: When you search, Trilium first looks for exact matches of your search terms. This handles the vast majority of searches (90%+) and returns results almost instantly.</li><li><strong>Phase 2 - Fuzzy Fallback</strong>: If Phase 1 doesn't find enough high-quality results (fewer than 5 results with good relevance scores), Trilium automatically adds fuzzy matching to find results with typos or spelling variations.</li><li><strong>Result Ordering</strong>: Exact matches always appear before fuzzy matches, regardless of individual scores. This ensures that when you search for \"project\", notes containing the exact word \"project\" will appear before notes containing similar words like \"projects\" or \"projection\".</li></ol><h3>Progressive Search Behavior</h3><ul><li><strong>Speed</strong>: Most searches complete using only exact matching</li><li><strong>Ordering</strong>: Exact matches appear before fuzzy matches</li><li><strong>Fallback</strong>: Fuzzy matching activates when exact matches return fewer than 5 results</li><li><strong>Identification</strong>: Results indicate whether they are exact or fuzzy matches</li></ul><h2>Search Performance</h2><p>Search system specifications:</p><ul><li>Content size limit: 10MB per note (previously 50KB)</li><li>Edit distance calculations for fuzzy matching</li><li>Infinite scrolling in Quick Search</li></ul><h2>Label and Relation Shortcuts</h2><p>The \"full\" syntax for searching by labels is:</p><pre><code class=\"language-text-x-trilium-auto\">note.labels.publicationYear = 1954</code></pre><p>For relations:</p><pre><code class=\"language-text-x-trilium-auto\">note.relations.author.title *=* Tolkien</code></pre><p>However, common label and relation searches have shortcut syntax:</p><pre><code class=\"language-text-x-trilium-auto\">#publicationYear = 1954\n~author.title *=* Tolkien</code></pre><h2>Separating Full-Text and Attribute Parts</h2><p>Search syntax allows combining full-text search with attribute-based search. For example, <code>tolkien #book</code> contains:</p><ol><li>Full-text tokens - <code>tolkien</code></li><li>Attribute expressions - <code>#book</code></li></ol><p>Trilium detects the separation between full text search and attribute/property search by looking for certain special characters or words that denote attributes and properties (e.g., #, ~, note.). If you need to include these in full-text search, escape them with a backslash so they are processed as regular text:</p><pre><code class=\"language-text-x-trilium-auto\">\"note.txt\" \n\\#hash \n#myLabel = 'Say \"Hello World\"'</code></pre><h2>Escaping Special Characters</h2><p>Special characters can be enclosed in quotes or escaped with a backslash to be used in full-text search:</p><pre><code class=\"language-text-x-trilium-auto\">\"note.txt\"\n\\#hash\n#myLabel = 'Say \"Hello World\"'</code></pre><p>Three types of quotes are supported: single, double, and backtick.</p><h2>Type Coercion</h2><p>Label values are technically strings but can be coerced for numeric comparisons:</p><pre><code class=\"language-text-x-trilium-auto\">note.dateCreated =* '2019-05'</code></pre><p>This finds notes created in May 2019. Numeric operators like <code>#publicationYear >= 1960</code> convert string values to numbers for comparison.</p>","_help_WbjlujkUhEb5": "<p>The single most common source of confusion is that the <code>=</code> sign means two <em>different</em> things depending on where it appears. Read this section once and the rest of search becomes predictable.</p><p>There are three matching modes:</p><figure class=\"table\"><table><thead><tr><th>Mode</th><th>How you trigger it</th><th>What it matches</th><th>Substring?</th><th>Fuzzy (typos)?</th></tr></thead><tbody><tr><td><strong>Default</strong></td><td>type words with no prefix</td><td>whole words <em>and</em> substrings, anywhere in title, content or attributes, relevance-ranked</td><td>Yes</td><td>Yes</td></tr><tr><td><strong>Exact full-text</strong></td><td>a leading <code>=</code> (e.g. <code>=sync</code>)</td><td>the exact whole word or phrase, ignoring surrounding punctuation</td><td>No</td><td>No</td></tr><tr><td><strong>Attribute / property equality</strong></td><td><code>=</code> inside a <code>#label=value</code> or <code>note.property=value</code> clause</td><td>the <em>entire</em> attribute or property value, exactly</td><td>No</td><td>No</td></tr></tbody></table></figure><h3>Default matching (no prefix)</h3><p><strong>Rule:</strong> typing words with no prefix finds notes that contain those words anywhere in the title, content or attributes, as whole words or as substrings. The closest matches are ranked first.</p><figure class=\"table\"><table><thead><tr><th>Query</th><th>Example note content</th><th>Matches?</th><th>Why</th></tr></thead><tbody><tr><td><code>sync</code></td><td><code>please sync the folders</code></td><td>Yes (ranked higher)</td><td>contains the exact word <code>sync</code></td></tr><tr><td><code>sync</code></td><td><code>synchronize the database now</code></td><td>Yes (ranked lower)</td><td><code>sync</code> is a substring of <code>synchronize</code></td></tr></tbody></table></figure><h3>Exact match with the <code>=</code> prefix</h3><p><strong>Rule:</strong> a leading <code>=</code> switches the full-text search to exact matching. It finds the whole word or phrase only, ignoring surrounding punctuation, with <strong>no</strong> substring and <strong>no</strong> fuzzy matching. Use it when a normal search returns too many near-matches.</p><figure class=\"table\"><table><thead><tr><th>Query</th><th>Example note content</th><th>Matches?</th><th>Why</th></tr></thead><tbody><tr><td><code>=sync</code></td><td><code>see (sync) mode</code></td><td>Yes</td><td><code>(sync)</code> is the whole word <code>sync</code>; punctuation is ignored</td></tr><tr><td><code>=sync</code></td><td><code>in sync, then continue</code></td><td>Yes</td><td><code>sync,</code> is the whole word <code>sync</code></td></tr><tr><td><code>=sync</code></td><td><code>he said \"sync\" out loud</code></td><td>Yes</td><td><code>\"sync\"</code> is the whole word <code>sync</code></td></tr><tr><td><code>=sync</code></td><td><code>synchronize the database now</code></td><td>No</td><td><code>=</code> never matches substrings</td></tr><tr><td><code>=sync</code></td><td><code>please send the file</code></td><td>No</td><td><code>=</code> never matches typos / fuzzy</td></tr></tbody></table></figure><p>To match an exact <strong>phrase</strong>, quote it after the <code>=</code> (single, double or backtick quotes all work). The phrase must appear as consecutive words, but punctuation between or around them is ignored:</p><figure class=\"table\"><table><thead><tr><th>Query</th><th>Example note (title or content)</th><th>Matches?</th><th>Why</th></tr></thead><tbody><tr><td><code>=\"project plan\"</code></td><td>title <code>Project Plan</code></td><td>Yes</td><td>the title is exactly the phrase</td></tr><tr><td><code>=\"project plan\"</code></td><td><code>the (project plan) is ready to share</code></td><td>Yes</td><td>the consecutive phrase appears; punctuation is ignored</td></tr><tr><td><code>=\"project plan\"</code></td><td><code>the plan for this project is late</code></td><td>No</td><td>the words are present but not consecutive</td></tr></tbody></table></figure><h3>Attribute and property equality (<code>=</code>, <code>!=</code>)</h3><p><strong>Rule:</strong> when <code>=</code> compares an attribute or property, as in <code>#label=value</code> or <code>note.title=value</code>, it is <strong>strict full-value equality</strong>: the <em>whole</em> value must equal what you typed, ignoring case and diacritics. This is <strong>not</strong> word matching. <code>!=</code> inverts it.</p><p>The examples below assume four notes: <em>Austria</em> (<code>#capital=Vienna</code>), <em>Somewhere</em> (<code>#capital=Vienna Austria</code>), <em>Czech Republic</em> (<code>#capital=Prague</code>) and <em>Switzerland</em> (<code>#capital=Zürich</code>).</p><figure class=\"table\"><table><thead><tr><th>Query</th><th>Example label value</th><th>Matches?</th><th>Why</th></tr></thead><tbody><tr><td><code>#capital=Vienna</code></td><td><code>Vienna</code></td><td>Yes</td><td>the whole value equals <code>Vienna</code></td></tr><tr><td><code>#capital=Vienna</code></td><td><code>Vienna Austria</code></td><td>No</td><td>the whole value is <code>Vienna Austria</code>, not <code>Vienna</code></td></tr><tr><td><code>#capital=\"Vienna Austria\"</code></td><td><code>Vienna Austria</code></td><td>Yes</td><td>quote a multi-word value to match it in full</td></tr><tr><td><code>#capital=Zurich</code></td><td><code>Zürich</code></td><td>Yes</td><td>equality ignores diacritics</td></tr><tr><td><code>#capital!=Vienna</code></td><td><code>Prague</code></td><td>Yes</td><td><code>!=</code> matches every value that is not <code>Vienna</code></td></tr><tr><td><code>#capital!=Vienna</code></td><td><code>Vienna</code></td><td>No</td><td><code>!=</code> excludes the exact value</td></tr></tbody></table></figure><blockquote><p><strong>Quick search relaxes this.</strong> The <a href=\"#root/_help_Ms1nauBra7gq\">Quick search</a> bar and autocomplete treat an attribute <code>=</code> as \"contains\", so <code>#capital=Vienna</code> typed there also matches <code>Vienna Austria</code>. The strict full-value equality described here applies only in the full Search.</p></blockquote><h3>Fuzzy operators (<code>~=</code> and <code>~*</code>)</h3><p><strong>Rule:</strong> the fuzzy operators tolerate typos. <code>~=</code> (fuzzy-equals) matches a value that is a close whole-word variant of your term. <code>~*</code> (fuzzy-contains) matches when your term appears anywhere inside the value, either as a fragment or as a near-miss. Both work on note properties such as <code>note.title</code> and <code>note.content</code>, and on labels (<code>#label</code>). Fuzzy operators accept terms of at least 3 characters, though how many typos each term tolerates depends on its length — see <em>Fuzzy tolerance</em> below.</p><p>The examples assume a note titled <code>Books</code> carrying the label <code>#author=Tolkien</code>, and a note whose content is <code>learn programming today</code>.</p><figure class=\"table\"><table><thead><tr><th>Query</th><th>Example value</th><th>Matches?</th><th>Why</th></tr></thead><tbody><tr><td><code>note.title ~= boks</code></td><td>title <code>Books</code></td><td>Yes</td><td>one edit away from <code>books</code></td></tr><tr><td><code>#author ~= tolkein</code></td><td>author <code>Tolkien</code></td><td>Yes</td><td><code>tolkein</code> is a typo of <code>tolkien</code></td></tr><tr><td><code>note.content ~* progr</code></td><td><code>learn programming today</code></td><td>Yes</td><td><code>progr</code> is a fragment of <code>programming</code></td></tr><tr><td><code>note.content ~* programing</code></td><td><code>learn programming today</code></td><td>Yes</td><td><code>programing</code> is one edit from <code>programming</code></td></tr></tbody></table></figure><h3>Fuzzy tolerance</h3><p><strong>Rule:</strong> how many typos are tolerated depends on the <strong>length</strong> of your search term. Short terms must match exactly, because a single edit is enough to turn one short word into an unrelated one; longer terms have greater tolerance.</p><figure class=\"table\"><table><thead><tr><th>Term length</th><th>Edits allowed</th></tr></thead><tbody><tr><td>1–3 characters</td><td>0 (exact only)</td></tr><tr><td>4–6 characters</td><td>1</td></tr><tr><td>7+ characters</td><td>2</td></tr></tbody></table></figure><figure class=\"table\"><table><thead><tr><th>Query</th><th>Term length</th><th>Example note content</th><th>Matches?</th><th>Why</th></tr></thead><tbody><tr><td><code>cat</code></td><td>3</td><td><code>a bright red car</code></td><td>No</td><td>No edits are allowed below 4 characters, so <code>cat</code> does not reach <code>car</code></td></tr><tr><td><code>carr</code></td><td>4</td><td><code>a blue debit card</code></td><td>Yes</td><td>1 edit is within budget for 4–6 character terms</td></tr><tr><td><code>ceck</code></td><td>4</td><td><code>the latest tech trends</code></td><td>No</td><td><code>ceck</code>→<code>tech</code> needs 2 edits; only 1 is allowed at this length</td></tr><tr><td><code>combinef</code></td><td>8</td><td><code>the values were combined together</code></td><td>Yes</td><td><code>combinef</code>→<code>combined</code> is 1 edit; up to 2 are allowed at 7+ characters</td></tr></tbody></table></figure><h3>Relevance ranking</h3><p><strong>Rule:</strong> results are ordered by <em>how well</em> they match, not merely whether they match. Exact whole-word and phrase matches rank above substring and fuzzy matches, and a note where your words appear as a consecutive phrase outranks one where they are scattered.</p><figure class=\"table\"><table><thead><tr><th>Query</th><th>Ranked higher</th><th>Ranked lower</th><th>Why</th></tr></thead><tbody><tr><td><code>sync</code></td><td><code>please sync the folders</code></td><td><code>synchronize the database now</code></td><td>exact word beats substring</td></tr><tr><td><code>you and me</code></td><td><code>I like you and me as a phrase</code></td><td><code>the menu is here and you know it</code></td><td>consecutive phrase beats scattered words</td></tr></tbody></table></figure><h3>What is searchable</h3><p>A search looks at more than the visible body text. All of the following are indexed and searchable:</p><ul><li>note titles,</li><li>note body content,</li><li>labels and relations (<a href=\"#root/_help_zEY4DaJG4YT5\">attributes</a>),</li><li>link URLs and the titles/descriptions of link previews,</li><li>the titles of notes that a note reference-links to.</li></ul><p>The last point is the least obvious: if a note's only content is a reference link to another note, searching for that other note's <strong>title</strong> still finds the linking note.</p><figure class=\"table\"><table><thead><tr><th>Query</th><th>Setup</th><th>Matches?</th><th>Why</th></tr></thead><tbody><tr><td><code>special topic</code></td><td>a note whose only content is a reference link to a note titled <code>Special Topic</code></td><td>Yes, and the linked target ranks first</td><td>the target's title is indexed into the linking note's searchable text</td></tr><tr><td><code>special</code></td><td>the same note (only a reference link to <code>Special Topic</code>)</td><td>Yes, one word from the target's title is enough</td><td>the indexed title is normalized just like body text, so even one lowercased word matches</td></tr><tr><td><code>zurich</code></td><td>a note whose only content is a reference link to a note titled <code>Zürich</code></td><td>Yes</td><td>the indexed title has its accents normalized, so the plain form matches the accented title</td></tr></tbody></table></figure><h3>Diacritics</h3><p><strong>Rule:</strong> accents are normalized on both sides, so an accented word and its plain form match each other.</p><figure class=\"table\"><table><thead><tr><th>Query</th><th>Example note content</th><th>Matches?</th></tr></thead><tbody><tr><td><code>ktory</code></td><td><code>slovo ktorý znamena nieco</code></td><td>Yes</td></tr><tr><td><code>ktorý</code></td><td><code>the word ktory appears here</code></td><td>Yes</td></tr></tbody></table></figure><h3>Regular expressions (<code>%=</code>)</h3><p><strong>Rule:</strong> the <code>%=</code> operator matches a property or label value against a regular expression.</p><figure class=\"table\"><table><thead><tr><th>Query</th><th>Example note content</th><th>Matches?</th></tr></thead><tbody><tr><td><code>note.content %= 'colou?r'</code></td><td><code>my favorite color of all</code></td><td>Yes</td></tr><tr><td><code>note.content %= 'colou?r'</code></td><td><code>my favourite colour of all</code></td><td>Yes</td></tr></tbody></table></figure>","_help_u3YFHC9tQlpm": "<p>Frequently used notes can be bookmarked, which will make them appear in the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a> for easy access.</p><h2>Configuring the launch bar</h2><p>If bookmarks don't appear in the launch bar, then most likely the bookmark section has been hidden. Go to the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a> configuration from the <a class=\"reference-link\" href=\"#root/_help_x3i7MxGccDuM\">Global menu</a> and ensure <em>Bookmarks</em> is in the <em>Visible Launchers</em> section.</p><h2>Bookmark folder</h2><p>Space in the left panel is limited, and you might want to bookmark many items. One possible solution is to bookmark a folder, so it shows its children:</p><p>To do this, bookmark a folder and assign it the <code>#bookmarkFolder</code> label.</p><h2>Mobile</h2><p>On mobile, bookmarks are only displayed starting with v0.102.0. Because of the more constrained screen size, the bookmarks are grouped under a single icon instead of displaying them as separate icons.</p><p>When pressed, a menu will appear listing all the bookmarks. Bookmark folders are also supported and will appear as sub-menus.</p>",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 749c29e4fe..79d9f46f82 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@@ -116,7 +116,7 @@ The same menu ends with a _Bulk actions_ section for applying changes such as ad## Viewing search results-Results appear below the search pane, by default in the _Search preview_ view. Each result is drawn as a **snippet card** with the note title, the path to it, a short excerpt of the matching text, and the attributes that matched.+Results appear below the search pane, by default in the _Search preview_ view. Each result is drawn as a **snippet card** with the note title, the path to it, a short excerpt of the matching text, and the attributes that matched. The excerpt of a code note keeps its indentation and is shown in the code font.To show the results as a plain note list instead, choose _List_ from the <a class="reference-link" href="../../Collections/Collection%20Properties.md">Collection Properties</a> bar. The _List_ view shows one row per note, with the note's title and content preview.diff --git a/packages/trilium-core/src/services/search/services/search.spec.ts b/packages/trilium-core/src/services/search/services/search.spec.tsindex 5dd5682052..3217858cfb 100644--- a/packages/trilium-core/src/services/search/services/search.spec.ts+++ b/packages/trilium-core/src/services/search/services/search.spec.ts@@ -1243,6 +1243,18 @@ describe("Search", () => {expect(snippet.split("\n")).toEqual([ "First line", "second line", "third line", "Next paragraph" ]);});+ it("keeps a code note's indentation in the snippet", () => {+ // Collapsing the whitespace of a line, as prose snippets do, would run the source together+ // and lose the nesting the code is read by.+ const noteBuilder = note("script.ts", { type: "code", mime: "text/typescript" });+ noteBuilder.note.getContent = () => "function main() {\n\tif (ready) {\n\t\trun();\n\t}\n}";+ rootNote.child(noteBuilder);++ const snippet = searchService.extractContentSnippet(noteBuilder.note.noteId, [ "run" ]);+ // Tabs are widened to the four spaces the code editor draws them as.+ expect(snippet.split("\n")).toEqual([ " if (ready) {", " run();", " }", "}..." ]);+ });+it("escapes angle brackets in the note title instead of dropping them", () => {// The title is interpolated into the autocomplete dropdown as raw HTML, so a title// containing markup-like text must come back escaped. Stripping only "<" would renderdiff --git a/packages/trilium-core/src/services/search/services/search.ts b/packages/trilium-core/src/services/search/services/search.tsindex dd243b8ae8..c3b49caf9c 100644--- a/packages/trilium-core/src/services/search/services/search.ts+++ b/packages/trilium-core/src/services/search/services/search.ts@@ -644,13 +644,26 @@ function extractContentSnippet(noteId: string, searchTokens: HighlightedTokenInf}}- // Normalize whitespace while preserving paragraph breaks- // First, normalize multiple newlines to double newlines (paragraph breaks)- content = content.replace(/\n\s*\n/g, "\n\n");- // Then normalize spaces within lines- content = content.split('\n').map(line => line.replace(/\s+/g, " ").trim()).join('\n');- // Finally trim the whole content- content = content.trim();+ if (note.type === "code") {+ // Code keeps its indentation and the spacing inside a line: collapsing them would show+ // the source as running prose rather than as the code it is.+ content = content+ .replace(/\r\n?/g, "\n")+ .replace(/\t/g, " ")+ .split("\n")+ .map((line) => line.trimEnd())+ .join("\n")+ .replace(/\n{3,}/g, "\n\n")+ .trim();+ } else {+ // Normalize whitespace while preserving paragraph breaks+ // First, normalize multiple newlines to double newlines (paragraph breaks)+ content = content.replace(/\n\s*\n/g, "\n\n");+ // Then normalize spaces within lines+ content = content.split('\n').map(line => line.replace(/\s+/g, " ").trim()).join('\n');+ // Finally trim the whole content+ content = content.trim();+ }if (!content) {return "";