The query language

The getref command is probably the most heavily used command. You use it to retrieve the references that you collected and saved in the database. To find a certain article or several related articles, all you have to do is to express your query in a language that refdb understands. The first section describes how to formulate search strings for your queries.

The getnote command used to locate extended notes is very similar. The specifics of this command will be described in the following section.

The reference query language

The syntax for the search string follows these rules:

The notes query language

The getnote command uses essentially the same query language as described above. However, there is a different set of field specifiers that you can use to locate extended notes:

:NID:

The unique id of an extended note.

:NCK:

The unique citation key of an extended note.

:NPY:

The date of an extended note.

:NTI:

The title of an extended note.

:NKW:

A keyword. This is a keyword attached to a note in order to categorize the latter, similar to a keyword in a reference.

:KW:

A keyword. This is a keyword that the note is linked to, i.e. a keyword that the note was attached to in order to supply additional information.

:AU:

The name of an author or editor. Use this field specifier to locate notes that are linked to a particular author.

:JF:, :JO:, :J1:, :J2:

The full, abbreviated, or user-abbreviated name of a periodical. Use this field specifier to locate notes that are linked to a periodical.

:ID:

The id of a reference. Use this field specifier to locate notes linked to a particular reference.

:CK:

The citation key of a reference. Use this field specifier to locate notes linked to a particular reference.

Some example queries

This section shows a few example queries to help you get familiar with the syntax. If you are not familiar with the regular expressions used here, please peruse the regular expressions section. We will not use any of the fancy switches of the getref command here, so the output will always be a simple listing on the screen.

Note: These examples assume that your database engine performs partial matches by default. This holds true for MySQL and PostgreSQL, wherease SQLite always attempts a full match. To emulate partial matches with the latter, append a percent sign (%) after each string to match. See also the section about SQL regular expressions.

We'll start with some easy queries. First we want to display a reference with a specific ID (25 in this example):

refdbc: getref :ID:=25

Next we want to list all references by a specific author. We'll use only the last name here. If several authors share this last name, we have to specify the initials as well, as shown in the second example. Note the use of the caret "^" which makes sure that the name actually starts with the capital M. Otherwise, a last name like "DeMillerette" would match as well.

refdbc: getref :AU:=^Miller
refdbc: getref :AU:=^Miller,J.D.

If Dr. Miller was a productive person, our previous query may have returned dozens of references. Now we try to filter out the paper or the papers that we really need. In the next example, we restrict the results to the years 1995 through 1999:

refdbc: getref :AU:=^Miller AND :PY:>1994 AND :PY:<2000

If this did not bring us close enough, we may try to include a coauthor:

refdbc: getref :AU:=^Miller AND :AU:=^Doe AND :PY:>1994 AND :PY:<2000

At this point we could narrow down the search by excluding other authors that often published with Dr. Miller, but are irrelevant here:

refdbc: getref :AU:=^Miller AND :AU:=^Doe AND NOT (:AU:=^Jones) AND :PY:>1994 AND :PY:<2000

Unfortunately, this is still a venerable list of publications. Now we try to include a few keywords. This is now a pretty complex query. It will return all references by the authors Miller and Doe between 1995 and 1999 with either the keyword "blood" or the keyword "animal" or the keywords "guanyl" and "cyclase", the latter only if both are present. The truncated spelling of "guanyl" ensures that both "guanylyl" and "guanylate" (which are interchangeable) will match. The funny expressions with the angle brackets ensure that the keywords will match regardless of whether they start with a capital letter or not.

refdbc: getref :AU:=^Miller AND :AU:=^Doe AND :PY:>1994 AND :PY:<2000 AND
(:KW:=[bB]lood OR :KW:=[aA]nimal OR (:KW:=[gG]uanyl AND :KW:=[cC]yclase))

And now for something completely different. If you've added a couple extended notes to your database, you can retrieve references that are attached to a specific extended note, e.g. to the note with the citation key "Miller1999":

refdbc: getnote :NCK:=biochemistry1999

If you want to see all notes which are attached to a reference with the citation key "Miller1999", use the following command:

refdbc: getnote :CK:=Miller1999

Tip: Remember that if you extend or modify a previous query, you don't have to retype everything: Just use the up arrow key to scroll through the previous commands, or use Ctrl-r to search for a specific query in the history.