Plone seems to be forgiving. Pretending that both, Plone 5 behavior and Plone 6 behavior, should be enabled, Plone runs fine and does what it should. The additional fields are added to the content type instances.
With conditional imports, everything is OK. The add-on is fit for Plone 5 and Plone 6.
try:
from plone.app.dexterity import textindexer
except ImportError:
from collective import dexteritytextindexer as textindexer
textindexer.searchable("organisation")
For the meticulous: Consider what could happen when - for whatever reason - both libraries are installed in the environment. This usually should not happen. But it might be the case.
One could check the version of a known and always installed package (e.g. Products.CMFPlone):
import Products.CMFPlone
from importlib.metadata import version
major_version = version('Products.CMFPlone').split('.')[0]
if major_version == 6:
from plone.app.dexterity import textindexer
elif major_version == 5:
from collective import dexteritytextindexer as textindexer
else:
raise Exception("...") # <- raise exception if needed