% This file is public domain. See the "Examples" chapter
% in the bib2gls user manual for a more detailed description
% of this file.

\documentclass[12pt,a4paper]{article}

\usepackage[T1]{fontenc}

\usepackage[record,% use bib2gls
 nostyles,% don't load default styles
% load glossary-bookindex.sty and patch styles:
 stylemods={bookindex},
 style=bookindex]{glossaries-extra}

% abbreviation style must be set before \GlsXtrLoadResources
\setabbreviationstyle[bacteria]{long-only-short-only}

\GlsXtrLoadResources[
 src=bacteria,% data in bacteria.bib
 category=bacteria,
 abbreviation-sort-fallback=long
]

\newcommand{\bacteriafont}[1]{\emph{#1}}

\glssetcategoryattribute{bacteria}{textformat}{bacteriafont}
\glssetcategoryattribute{bacteria}{glossnamefont}{bacteriafont}

\renewcommand*{\glsxtrbookindexname}[1]{%
 \glsifcategory{#1}{bacteria}
 {\glossentrynameother{#1}{long}}%
 {\glossentryname{#1}}%
}

\begin{document}
\section{First Use}

\gls{cbotulinum}, \gls{pputida}, \gls{cperfringens},
\gls{bsubtilis}, \gls{ctetani}, \gls{pcomposti},
\gls{pfimeticola}, \gls{cburnetii}, \gls{raustralis},
\gls{rrickettsii}.

\section{Next Use}

\gls{cbotulinum}, \gls{pputida}, \gls{cperfringens},
\gls{bsubtilis}, \gls{ctetani}, \gls{pcomposti},
\gls{pfimeticola}, \gls{cburnetii}, \gls{raustralis},
\gls{rrickettsii}.

\printunsrtglossary[title={Bacteria Index}]
\end{document}
