From b201be5d5a22c4eaf56089cbffd0ae965b7d0b11 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 21 Jul 2026 15:27:55 -0400 Subject: [PATCH] Rename the similarity condition and quick-search mode to bestMatch "bestMatch" names what the condition does -- rank results by how well they match the text -- rather than the current scoring mechanism, so the name can account for later changes to how it works. Rename the condition-facing identifiers with it; the embeddings engine keeps its similarity vocabulary. --- chrome/content/zotero/collectionViewItemTree.jsx | 4 ++-- chrome/content/zotero/elements/quickSearchTextbox.js | 6 +++--- chrome/content/zotero/xpcom/collectionTreeRow.js | 12 ++++++------ chrome/locale/en-US/zotero/zotero.ftl | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/chrome/content/zotero/collectionViewItemTree.jsx b/chrome/content/zotero/collectionViewItemTree.jsx index b83ad4ad6d..7f16d2b3c1 100644 --- a/chrome/content/zotero/collectionViewItemTree.jsx +++ b/chrome/content/zotero/collectionViewItemTree.jsx @@ -749,9 +749,9 @@ class CollectionViewItemTreeRowProvider extends ItemTreeRowProvider { refresh = true; madeChanges = true; } - // Under an active similarity quick search, handle removals with a full refresh too + // Under an active best-match quick search, handle removals with a full refresh too else if (['remove', 'delete', 'trash'].includes(action) - && collectionTreeRows.some(row => row.isSimilaritySearch())) { + && collectionTreeRows.some(row => row.isBestMatchSearch())) { this.itemTree.invalidateRowCache(ids); refresh = true; madeChanges = true; diff --git a/chrome/content/zotero/elements/quickSearchTextbox.js b/chrome/content/zotero/elements/quickSearchTextbox.js index e01d9a72c5..43180e7034 100644 --- a/chrome/content/zotero/elements/quickSearchTextbox.js +++ b/chrome/content/zotero/elements/quickSearchTextbox.js @@ -52,7 +52,7 @@ everything: Zotero.getString('quickSearch.mode.everything') }; if (Zotero.Embeddings.isEnabled()) { - modes.similarity = Zotero.getString('quickSearch-mode-similarity'); + modes.bestMatch = Zotero.getString('quickSearch-mode-similarity'); } return modes; } @@ -131,7 +131,7 @@ this._advancedButton = advancedButton; } - // Dropdown selecting how many results the similarity mode keeps; + // Dropdown selecting how many results the best-match mode keeps; // shown in place of the Advanced Search button let topKList = document.createXULElement('menulist'); topKList.id = 'zotero-tb-search-topk'; @@ -256,7 +256,7 @@ // Advanced Search doesn't apply to semantic search, so swap its // button for the similarity result-count dropdown - let isSimilarity = mode === 'similarity'; + let isSimilarity = mode === 'bestMatch'; if (this._advancedButton) { this._advancedButton.hidden = isSimilarity; } diff --git a/chrome/content/zotero/xpcom/collectionTreeRow.js b/chrome/content/zotero/xpcom/collectionTreeRow.js index 1e78304fde..a5fe3d050e 100644 --- a/chrome/content/zotero/xpcom/collectionTreeRow.js +++ b/chrome/content/zotero/xpcom/collectionTreeRow.js @@ -384,7 +384,7 @@ Zotero.CollectionTreeRow.prototype.getSearchResults = async function (asTempTabl // ranking succeeds, so a ranking failure (e.g. model not yet // downloaded) doesn't leave the full unranked scope cached as the // search result. - if (this.isSimilaritySearch()) { + if (this.isBestMatchSearch()) { results = await Zotero.Embeddings.rankItemIDs( this.searchText, results, { limit: Zotero.Prefs.get('search.quicksearch-semantic-topK') } @@ -507,9 +507,9 @@ Zotero.CollectionTreeRow.prototype.getSearchObject = async function (options = { // Add Quick Search unless advanced search is enabled if (this.searchText && !this.advancedSearch) { let mode = this.searchMode || Zotero.Prefs.get('search.quicksearch-mode'); - // The similarity mode isn't a SQL condition -- the base search returns + // The best-match mode isn't a SQL condition -- the base search returns // the full scope and getSearchResults() re-ranks it semantically. - if (mode !== 'similarity') { + if (mode !== 'bestMatch') { s2.addCondition('quicksearch-' + mode, 'contains', this.searchText); } } @@ -637,7 +637,7 @@ Zotero.CollectionTreeRow.prototype.setSearch = function (searchText, mode = null // has to trigger a re-run -- as does changing the similarity top-K, which // lives in its own pref. With no search text, neither matters. let effectiveMode = mode || Zotero.Prefs.get('search.quicksearch-mode'); - let topK = effectiveMode === 'similarity' + let topK = effectiveMode === 'bestMatch' ? Zotero.Prefs.get('search.quicksearch-semantic-topK') : null; if (this.searchText === searchText @@ -724,9 +724,9 @@ Zotero.CollectionTreeRow.prototype.isSearchMode = function () { * Whether an active quick search on this row is in the semantic similarity * mode -- i.e. the results are a ranked top-K set rather than a plain filter */ -Zotero.CollectionTreeRow.prototype.isSimilaritySearch = function () { +Zotero.CollectionTreeRow.prototype.isBestMatchSearch = function () { return !!this.searchText && !this.advancedSearch - && (this.searchMode || Zotero.Prefs.get('search.quicksearch-mode')) === 'similarity'; + && (this.searchMode || Zotero.Prefs.get('search.quicksearch-mode')) === 'bestMatch'; }; Zotero.CollectionTreeRow.prototype.isSortable = function () { diff --git a/chrome/locale/en-US/zotero/zotero.ftl b/chrome/locale/en-US/zotero/zotero.ftl index 0ea2edbeb2..c68513b674 100644 --- a/chrome/locale/en-US/zotero/zotero.ftl +++ b/chrome/locale/en-US/zotero/zotero.ftl @@ -838,7 +838,7 @@ quicksearch-input = .placeholder = { $placeholder } .aria-description = { $placeholder } quicksearch-semantic-topk = - .aria-label = Number of similarity search results + .aria-label = Number of best-match search results quickSearch-mode-similarity = Similarity advanced-search = Advanced Search