I haven’t seen this specifically requested anywhere. I’m happy to open a PR if you’re interested. I have an implementation here: Support page taxonomies and extras in the search index · mrmekon/zola@f27879d · GitHub
Summary
Optionally include the text values from user-specified taxonomies and/or front-matter extra fields when generating search indexes, allowing searching of the metadata in addition to post title and contents.
Reasoning
It’s not unusual for important information to be encoded in a page’s metadata, which can be taxonomies or custom fields in the “extra” section. That information does not currently end up in the generated search index files, which can lead to a surprising experience.
As a specific example, I have a site for movie review, and information like directors, filming locations, actors/actresses, and genres are encoded as either taxonomies or custom extra fields. All of these would ideally be considered in searches.
Implementation
Example usage is in the commit message, so I won’t repeat it all here. But configuration looks like:
[search]
include_title = true
include_content = true
include_taxonomies = ["directors", "genres"]
include_extras = ["actors", "alt-titles"]
index_format = "fuse_json"
I only personally use fuse.js, so that is implemented and tested locally and I can confirm that it works as expected. I also put something together for elasticlunr, but I’ve only manually inspected the JSON to ensure it looks ok.
The fuse.js index supports arbitrary JSON objects, so both taxonomies and extras are implemented as maps of keys to arrays of strings, matching how they’re defined in Zola’s internal data structures.
I’m not sure if elasticlunr supports nested structures, but the existing Zola implementation doesn’t seem to, so I concatenated values into a string with an arbitrarily chosen separator (::). It doesn’t seem like it supports optional entries either, so it gets empty strings when a page doesn’t define the requested fields.
It’s not intentionally optimized, and performs string allocations per page (especially the elasticlunr implementation, for concatenation), so I imagine it could slow down very large sites. But it’s optional and only indexes the keys the user requests, so it’s an opt-in problem. I did not include any way to request all, or globs, or anything fancy.
(And while I’m here, thank you very much for Zola! I’ve been using it happily for a few years, and love it!)