As discussed at the Koha Hackfest 2025: Sometimes we need conditional indexing of fields (008 based on leader, 264 based on indicator). Instead of complicating the yml file and the DB, we can add a hook after the ES record has been created but before it is sent to ES. This hook should get the ES record and the MARC record (and maybe even the biblio/auth object) and return the modified ES record. So you can implement whatever weird conditionals etc you need, or even any other modifications (eg getting number of items, advanced geo stuff, ..) without us having to make core very complex.
See bug 36433 *** This bug has been marked as a duplicate of bug 36433 ***