Skip to content

Name index

Every time you type [[, Obsidian builds the list of things you could link to by walking every file in the vault — reading each one’s metadata and parsing its aliases — and then throws that list away when the popover closes. The next [[ does the whole walk again.

The Names module keeps that list as an index instead, and answers app.metadataCache.getLinkSuggestions() from it.

Measured on a generated vault (Obsidian 1.14.2, notes with no frontmatter at all, so a floor rather than a typical cost):

notes built-in, per [[ open from the index
20 000 ~23 ms ~0.005 ms
90 000 ~108 ms ~0.005 ms

Honest note: in a tiny vault like this one you will not feel any of that — the built-in walk is over before you see the popover. What this note shows is what the module does, and the one thing it can do that the built-in list cannot do at all: ask the question backwards.

The built-in list is flat and unkeyed, so “which notes are called Literature review?” can only be answered by scanning it. The index is keyed by name, so it answers directly — counting a note’s own name and its aliases, case-insensitively, with runs of whitespace collapsed, exactly as Obsidian resolves a wikilink.

Research note answers to two aliases, so all three of these name the same note:

Button: What does "Literature review
await require('/demoSetup.ts').showNamesFor(app, 'Literature review');
Button: What does "background research
await require('/demoSetup.ts').showNamesFor(app, 'background research');
Button: What does "Research note
await require('/demoSetup.ts').showNamesFor(app, 'Research note');

Each button switches the Names module on for you — it is off by default — and reports the notes carrying that name, plus how many link targets the index and the built-in implementation each offer. Those two counts agree: the index is a faster answer to the same question, not a different one.

They agree unless you ask for the one thing that changes the answer rather than its speed — Offer titles in the [[ autocomplete, which is off by default and is 06 Titles’s subject. With it on the indexed count is the larger of the two, by exactly the title entries appended to the end.

The answer is a list, and deliberately an unranked one. Several notes may declare the same alias, and which of them you meant is a question about your context — the note you are editing, what it already links to — which the index does not have and does not guess at.

With the module on, open any note and type [[Lit — Research note is offered under its alias, exactly as it was before. That is the point: nothing about the autocomplete changes except where the list came from.

Button: Type [[Lit in the autocomplete playground
await require('/demoSetup.ts').typeLinkInPlayground(app);

The button switches the Names module on, opens Autocomplete playground and types [[Lit at its end, so the popover opens with Literature review in it. Keep typing there, or pick the entry to see the link it writes.

Button: Reset the autocomplete playground
await require('/demoSetup.ts').resetPlayground(app);

The reset puts the playground back as it shipped. By hand, delete the lines you typed at its end.

Button: Switch the Names module off (the default)
await require('/demoSetup.ts').changeSettings(app, { isNamesModuleEnabled: false });

Switching the module off unloads it completely — the index, its listeners and the patched getLinkSuggestions all go with it, and Obsidian’s own walk answers again. See 04 Settings for the rest of the options.