umbraco / Umbraco.Cms.Integrations

MIT License
36 stars 21 forks source link

Algolia Search - Indexing of non-string values #151

Closed geann closed 10 months ago

geann commented 10 months ago

Sometimes we need to index non-string fields in Algolia. For example, we have a MultiNodeTreePicker category field and we want to index it as an array of names or GUIDs. Currently we have to serialize this data because the method GetValue() of AlgoliaSearchPropertyIndexValueFactory can return only string values. The problem with this approach is that it is then stored as a text value in Algolia rather than an object:

image

Even though full text search by categories works ok, there is an issue with facets as Algolia doesn't parse serialised objects and instead treats them as text: image

I tracked usage of string values down to the class Record.cs where the Data property is of type Dictionary<string, string>. Do you think this property can be changed to Dictionary<string, object> to cater for non-string values?


This item has been added to our backlog AB#34719

thenexus00 commented 10 months ago

It is a json string that you need so that comes into the Algolia search objects which can process in there. I have internal fixes and I did do a pull request so things like Multi tree node picker renders out the name. You then do work in your Algolia to handle that.

acoumb commented 10 months ago

Hi @geann ,

Thank you for the reported issue and your PR.

I've done some testing of different use cases and as a result we would need to prepare in the coming weeks a new version of the package that will provide additional converters for sending data to Algolia, and options for developers to manage the converters themselves, by adding new or removing existing ones.

I will update here with the progress.

Thank you, Adrian

geann commented 10 months ago

That's great, thank you @acoumb!

acoumb commented 10 months ago

Hi @geann ,

We have released version 2.0.0 with changes to the way converters work (more details here).

Please update to the new version and let me know how it goes.

Thank you, Adrian