feat: add ext: operator for file extension filtering in advanced search
- Add ext: operator support to query parser in backend and frontend - Update search documentation in README and help modal with ext: examples - Parse ext: operator to extract file extension filter (strips leading dot, converts to lowercase) - Filter search candidates by file extension in advanced_search function - Add ext chip display in search UI alongside existing tag/vault/title/path chips - Update API documentation and function
This commit is contained in:
+8
-2
@@ -305,11 +305,11 @@
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Query Parser — extracts operators (tag:, #, vault:, title:, path:)
|
||||
// Query Parser — extracts operators (tag:, #, vault:, title:, path:, ext:)
|
||||
// ---------------------------------------------------------------------------
|
||||
const QueryParser = {
|
||||
parse(raw) {
|
||||
const result = { tags: [], vault: null, title: null, path: null, freeText: "" };
|
||||
const result = { tags: [], vault: null, title: null, path: null, ext: null, freeText: "" };
|
||||
if (!raw) return result;
|
||||
const tokens = this._tokenize(raw);
|
||||
const freeTokens = [];
|
||||
@@ -326,6 +326,8 @@
|
||||
result.title = tok.slice(6).replace(/"/g, "").trim();
|
||||
} else if (lower.startsWith("path:")) {
|
||||
result.path = tok.slice(5).replace(/"/g, "").trim();
|
||||
} else if (lower.startsWith("ext:")) {
|
||||
result.ext = tok.slice(4).replace(/"/g, "").trim().replace(/^\./, "").toLowerCase();
|
||||
} else {
|
||||
freeTokens.push(tok);
|
||||
}
|
||||
@@ -657,6 +659,10 @@
|
||||
this._addChip("path", `path:${parsed.path}`, parsed.path);
|
||||
hasChips = true;
|
||||
}
|
||||
if (parsed.ext) {
|
||||
this._addChip("ext", `ext:${parsed.ext}`, parsed.ext);
|
||||
hasChips = true;
|
||||
}
|
||||
this._container.hidden = !hasChips;
|
||||
},
|
||||
clear() {
|
||||
|
||||
+3
-1
@@ -776,9 +776,11 @@
|
||||
<li><code>vault:IT</code> : Rechercher dans un vault spécifique</li>
|
||||
<li><code>title:kubernetes</code> : Chercher dans les titres uniquement</li>
|
||||
<li><code>path:recettes/soupes</code> : Filtrer par chemin</li>
|
||||
<li><code>ext:md</code> : Filtrer par type de fichier</li>
|
||||
<li><code>"phrase exacte"</code> : Recherche de phrase entre guillemets</li>
|
||||
</ul>
|
||||
<p><strong>Exemple</strong> : <code>tag:linux vault:IT serveur web</code> recherche "serveur web" dans le vault IT avec le tag linux.</p>
|
||||
<p><strong>Exemples</strong> : <code>ext:sh</code> recherche dans les scripts bash, <code>ext:py</code> dans les scripts Python, <code>ext:md</code> dans les fichiers Markdown.</p>
|
||||
<p><strong>Exemple combiné</strong> : <code>tag:linux vault:IT ext:md serveur web</code> recherche "serveur web" dans les fichiers Markdown du vault IT avec le tag linux.</p>
|
||||
|
||||
<h3>Autocomplétion</h3>
|
||||
<p>L'autocomplétion vous aide à trouver rapidement :</p>
|
||||
|
||||
Reference in New Issue
Block a user