Search literature notes in a library-catalog interface

Hello, I created an interface for searching literature notes that is quick and easy to use.

This script provides a library-catalog interface to search literature notes, i.e. source metadata, plus your notes or PDF annotations imported via a plugin, for example, Zotero Integration.

The setup consists of a Dataview script (in two files) that you can find here: GitHub - erazlogo/obsidian-lit-notes-search: Library-catalog interface to search literature notes in Obsidian.

It is a separate note that looks like a library catalog search, including an option to search for “everything” (keyword). Search results appear in real time in a table in the same note:

gif

  • keyword finds text in the entire note text + note title.
  • note-title finds text in the file name of your literature note (usually your source citekey).
  • For text fields, this is a case-insensitive phrase search.
  • Enter dates as YYYY-MM-DD, <YYYY-MM-DD and >YYYY-MM-DD.
  • Enter tags as #tag1 #tag2.
  • Enter exact field title and asc/desc to sort by field.
  • Leave sort fields blank to sort by note-title, desc.

Necessary plugins and settings in Obsidian:

  • Live Preview: On
  • Dataview (Community plugins; Settings: Enable Javascript Queries - On, Automatic View Refreshing - On)
  • A plugin or script to import your source metadata from a reference manager or bibtex file

The idea is to get you to your own writing faster. Once you can easily locate ideas within literature notes, you can quickly link them to your own concept notes and then concentrate on the famous Obsidian feature, writing-via-linking.

This script can also be adapted to search any Dataview fields in your vault.

3 Likes

Apologies for my spectacular dimness, but I am having trouble getting this to work (it looks terrific by the way!). Here is an eg of my literature note yaml:

title: "Chernobyl and the Sublime Tourist"

authors: ["Jeff Goatcher", "Viv Brunsden"]

itemType: Article

publicationTitle:  '[[Tourist Studies]]'

date: 2011

dateAdded: [[2020-12-07]]

url: http://tou.sagepub.com/content/11/2/115

DOI: https://doi.org/10.1177/1468797611424956

citeKey: goatcher2011

tags: Chernobyl, recovery, visual-sociology, post-modern-sublime, zotero, reference

created: 2020-11-15T17:57:24 

lastModified: 2021-12-07T00:23:11 

I am unsure just what to change inscript.js and/or search.md. Any hand-holding much appreciated!

In addition to changing the folder names (see readme on github), you need to change these:

search.md:
author:: → authors::
publication:: → publicationTitle::

view.js (all instances):
current.author / page.author / p.author → current.authors / page.authors / p.authors
current.publication / page.publication / p.publication → current.publicationTitle / page.publicationTitle / p.publicationTitle

This will make it possible for you to search by author, title, publication title, and keyword. The fields you don’t have (comment, start-date, etc) you can just delete from search.md and leave as is in the script–they will be excluded automatically.

I don’t use YAML tags, but the tag search should also work without any changes. You’ll need to search for tag #Chernobyl but it will find the note with Chernobyl in YAML tags.

Your authors are entered as a list I think, so you might only be able to search by exact author as entered: Jeff Goatcher but not Goatcher. To make them searchable by part of name, I separate the authors by semicolon rather than comma. But you need to test this–maybe I am wrong and Goatcher will work.

Your date has to be formatted YYYY-MM-DD for the search to work, unfortunately. So your current date 2011 would have to be entered as '2011-01-01` to be read as a date for search purposes. If you change this, the date search will work also.

Thank you for such a fulsome reply. Unfortunately, I cannot get it to work. I must close my pooter for now, but will continue to jiggle with it later… in the meantime, this looks unusual to my untrained eye; have I got this bit correct (backticks notwithstanding)…
‘’‘dataviewjs
await dv.view("/Templates/Scripts", { });
‘’’

You need to omit the slash before “Templates”:

await dv.view(“Templates/Scripts”, { });