Skip to content

Commit 10ee144

Browse files
authored
Merge pull request #74 from Will-DiscoveryAgency/hotfix/AlgoliaRecordBuilderFix
Fix issue with Algolia RecordBuilder where string arrays are pushed a…
2 parents 61a9fbf + aa4037b commit 10ee144

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/Umbraco.Cms.Integrations.Search.Algolia/Builders/RecordBuilder.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@ public RecordBuilder BuildFromContent(IContent content, Func<IProperty, bool> fi
1515
foreach (var property in content.Properties.Where(filter ?? (p => true)))
1616
{
1717
if (!_record.Data.ContainsKey(property.Alias))
18-
_record.Data.Add(property.Alias, property.GetValue().ToString());
18+
{
19+
string propValue = property.GetValue().ToString();
20+
if (property.GetValue() is IEnumerable<object> list)
21+
{
22+
propValue = string.Join(",", list.Select(p => p.ToString()));
23+
}
24+
_record.Data.Add(property.Alias, propValue);
25+
}
1926
}
2027

2128
return this;
@@ -28,7 +35,14 @@ public RecordBuilder BuildFromContent(IPublishedContent publishedContent, Func<I
2835
foreach (var property in publishedContent.Properties.Where(filter ?? (p => true)))
2936
{
3037
if (!_record.Data.ContainsKey(property.Alias) && property.HasValue())
31-
_record.Data.Add(property.Alias, property.GetValue().ToString());
38+
{
39+
string propValue = property.GetValue().ToString();
40+
if (property.GetValue() is IEnumerable<object> list)
41+
{
42+
propValue = string.Join(",", list.Select(p => p.ToString()));
43+
}
44+
_record.Data.Add(property.Alias, propValue);
45+
}
3246
}
3347

3448
return this;

0 commit comments

Comments
 (0)