diff --git a/chrome/content/zotero/xpcom/data/search.js b/chrome/content/zotero/xpcom/data/search.js index eca9b4aa43..0470b2d495 100644 --- a/chrome/content/zotero/xpcom/data/search.js +++ b/chrome/content/zotero/xpcom/data/search.js @@ -328,7 +328,8 @@ Zotero.Search.prototype.addCondition = function (condition, operator, value, req this.addCondition('creator', operator, part.text, false); if (condition == 'quicksearch-everything') { - this.addCondition('annotation', operator, part.text, false); + this.addCondition('annotationText', operator, part.text, false); + this.addCondition('annotationComment', operator, part.text, false); if (part.inQuotes) { this.addCondition('fulltextContent', operator, part.text, false); diff --git a/chrome/content/zotero/xpcom/data/searchConditions.js b/chrome/content/zotero/xpcom/data/searchConditions.js index 1105ad3a67..11fd2c53a3 100644 --- a/chrome/content/zotero/xpcom/data/searchConditions.js +++ b/chrome/content/zotero/xpcom/data/searchConditions.js @@ -490,13 +490,23 @@ Zotero.SearchConditions = new function(){ }, { - name: 'annotation', + name: 'annotationText', operators: { contains: true, doesNotContain: true }, - table: 'annotations', - field: 'text' + table: 'itemAnnotations', + field: 'text', + }, + + { + name: 'annotationComment', + operators: { + contains: true, + doesNotContain: true + }, + table: 'itemAnnotations', + field: 'comment', }, { diff --git a/chrome/locale/en-US/zotero/zotero.properties b/chrome/locale/en-US/zotero/zotero.properties index 1dd6781042..68a89f87df 100644 --- a/chrome/locale/en-US/zotero/zotero.properties +++ b/chrome/locale/en-US/zotero/zotero.properties @@ -789,7 +789,8 @@ searchConditions.dateModified = Date Modified searchConditions.fulltextContent = Attachment Content searchConditions.programmingLanguage = Programming Language searchConditions.fileTypeID = Attachment File Type -searchConditions.annotation = Annotation +searchConditions.annotationText = Annotation Text +searchConditions.annotationComment = Annotation Comment fulltext.indexState.indexed = Indexed fulltext.indexState.unavailable = Unknown diff --git a/test/tests/searchTest.js b/test/tests/searchTest.js index 3d550364e3..ea15597623 100644 --- a/test/tests/searchTest.js +++ b/test/tests/searchTest.js @@ -360,6 +360,36 @@ describe("Zotero.Search", function() { }); }); + describe("annotationText", function () { + it("should return matches for annotation text", async function () { + var attachment = await importPDFAttachment(); + var annotation = await createAnnotation('highlight', attachment); + var str = annotation.annotationText.substr(0, 7); + + var s = new Zotero.Search(); + s.libraryID = userLibraryID; + s.addCondition('joinMode', 'any'); + s.addCondition('annotationText', 'contains', str); + var matches = await s.search(); + assert.sameMembers(matches, [annotation.id]); + }); + }); + + describe("annotationComment", function () { + it("should return matches for annotation comment", async function () { + var attachment = await importPDFAttachment(); + var annotation = await createAnnotation('note', attachment); + var str = annotation.annotationComment.substr(0, 7); + + var s = new Zotero.Search(); + s.libraryID = userLibraryID; + s.addCondition('joinMode', 'any'); + s.addCondition('annotationComment', 'contains', str); + var matches = await s.search(); + assert.sameMembers(matches, [annotation.id]); + }); + }); + describe("fulltextWord", function () { it("should return matches with full-text conditions", function* () { let s = new Zotero.Search();