Biblatex/Biber – Adding Bibliography Entries by Keyword

biberbiblatex

I would like to print a bibliography which includes all entries with a certain keyword (and possibly some additional entries).

I know that I can filter by keyword when I print the bibliography using

\printbibliography[keyword=<keyword>]

but this will only print entries which I have cited. I could, of course, use

\nocite{*}

to add all entries to the bibliography and then print just those I want.

However, this will make my .bbl file huge as my database is enormous.

Another possibility is to use Biber or another tool to prepare a document-specific .bib file containing only those entries with the keyword. However, this would need to be recreated if additional entries with the keyword are added to my main database files.

Here's an MWE to play with, annotated to indicate the way I'd like it to work ;), and the disadvantages of the way it (almost) works.

The issue of excluding explicitly cited entries is less of an issue for me. The thing I'd really like to work around is adding the entire database contents to the .bbl.

\RequirePackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{new-stuff,
    author          =   {Watt, Brian},
    title           =   {Happy Times with Penguins},
    publisher       =   {Harvard University Press},
    address         =   {Cambridge, MA},
    year            =   1995,
    pagination      =   {section},
    keywords        =   {happy}}
@book{den-coll,
  author                =   {Till, Jr., Dennis E.},
    booktitle           =   {Penguin Land and Further North: Human Influence},
    title               =   {Penguin Land and Further North: Human Influence},
    publisher           =   {Oxford University Press},
    year                =   2008,
    address             =   {Oxford and New York},
    keywords            =   {penguin, human}}
@book{old-stuff,
  author                =   {Harvey, Jr., Dennis E.},
    booktitle           =   {Penguin Land and Further North: Human Influence},
    title               =   {Penguin Land and Further North: Human Influence},
    publisher           =   {Someone \& Daughters},
    year                =   1567,
    address             =   {Oxford},
    bookpagination      =   {paragraph},
    keywords            =   {penguin}}
\end{filecontents}
\documentclass{article}
\usepackage[defernumbers=true]{biblatex}
\bibliography{\jobname}
\begin{document}

\cite{old-stuff}

% what I would like to work
% \nocite[keyword=happy]
% \printbibliography

% what does work - except that \cite{old-stuff} is ignored and, more importantly, den-coll is added to the .bbl
\nocite{*}
\printbibliography[keyword=happy]

\end{document}

Best Answer

Update: This is now possible with biber 2.14/biblatex 3.14, both in their respective development folders on github [1][2]:

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@book{new-stuff,
    author          =   {Watt, Brian},
    title           =   {Happy Times with Penguins},
    publisher       =   {Harvard University Press},
    address         =   {Cambridge, MA},
    year            =   1995,
    pagination      =   {section},
    keywords        =   {happy}}
@book{den-coll,
  author                =   {Till, Jr., Dennis E.},
    booktitle           =   {Penguin Land and Further North: Human Influence},
    title               =   {Penguin Land and Further North: Human Influence},
    publisher           =   {Oxford University Press},
    year                =   2008,
    address             =   {Oxford and New York},
    keywords            =   {penguin, human}}
@book{old-stuff,
  author                =   {Harvey, Jr., Dennis E.},
    booktitle           =   {Penguin Land and Further North: Human Influence},
    title               =   {Penguin Land and Further North: Human Influence},
    publisher           =   {Someone \& Daughters},
    year                =   1567,
    address             =   {Oxford},
    bookpagination      =   {paragraph},
    keywords            =   {penguin}}
\end{filecontents*}

\usepackage[defernumbers=true]{biblatex}
\addbibresource{\jobname.bib}
\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[nocited, final]
      \step[fieldsource=keywords, notmatch=happy, final]
      \step[entrynull]
    }
  }
}

\begin{document}

\cite{old-stuff}

\nocite{*}
\printbibliography

\end{document}

This removes entries during parsing the data sources which are \nocited or which don't have the keyword.

enter image description here

Related Question