Closed piotrkrajewskicn closed 4 months ago
Hi @piotrkrajewskicn ,
Thank you for your PR, it's fantastic to see the extension you've put in place. Before merging it, could you please, share with me a specific use case, maybe use one of the test sites for reference.
Regards, Adrian
Hi,
I believe that there is a need to add custom record values by the developers using the Algolia plugin, just as it is possible in Umbraco Examine (e.g. by subscribing to the TransformingIndexValues event).
I implemented a way to extend the default
Record
by the library users. As an example, let's assume we add a new content type calledArticle
and we'd like to index an additionalcustomField
property. One can first extend the defaultRecord
class and add their custom properties, for example:Then one would need to implement a generic
IRecordBuilder<>
interface where the generic type needs to extend PublishedContentModel so in this case that'd beArticle
. The methodGetRecord
needs to return the new extended Record type and set the extra properties values:In the end the new record builder needs to be registered in services, for example:
As a result after rebuilding an index, the Algolia index contains the extra field value:
Let me know what you think of such solution and if it can be added to the plugin in this or different form, thanks!