Including content and media in custom Examine inde...
# help-with-umbraco
d
I'm following the docs (https://docs.umbraco.com/umbraco-cms/reference/searching/examine/indexing#creating-your-own-index) on creating a custom Examine index. I'd like to include media items in the same index (the media items share some common properties with the indexed content, such as tags, text description etc). The documentation seems to be geared towards indexing only content and I'm struggling to see how to extend it to include media. Does anyone have an example of how to do this, or can anyone point me in the right direction?
m
d
The content and media populators in Umbraco automatically populate any index that extends
UmbracoContentIndex
, so you could try using that as a base class for your custom index. You don't even need to add populators or valueset builders or validators. It all happens automatically. If, for some reason, you really don't want to do that, then the magic is in the interface
IUmbracoContentIndex
. That is a marker interface that the standard populators of Umbraco actually look for. You can add that interface to your custom index instead
I usually keep a clone of Umbraco's repo locally so that I can dig through the source and find out how these things work
d
Thanks for the pointers folks. I've ended up going down the route of enhancing the External Indexer rather than creating a custom index, which seemed a bit more straightforward.
m
We always recommend that you use the existing built in ExternalIndex. You should then query based on the NodeTypeAlias instead of creating a new separate index based on that particular node type.
😆
d
It wasn't quite that clear cut on this project (an upgrade of a v7 site which does use custom indexes) but on balance the better approach.
m
sorry just being faceious... forgive me.. 🤓
5 Views