diff --git a/src/Exceptionless.Core/Exceptionless.Core.csproj b/src/Exceptionless.Core/Exceptionless.Core.csproj
index df96d642c2..3411632ac7 100644
--- a/src/Exceptionless.Core/Exceptionless.Core.csproj
+++ b/src/Exceptionless.Core/Exceptionless.Core.csproj
@@ -34,7 +34,7 @@
-
+
diff --git a/src/Exceptionless.Core/Models/PersistentEvent.cs b/src/Exceptionless.Core/Models/PersistentEvent.cs
index 229127796b..cf0c834d25 100644
--- a/src/Exceptionless.Core/Models/PersistentEvent.cs
+++ b/src/Exceptionless.Core/Models/PersistentEvent.cs
@@ -1,10 +1,11 @@
using System.Diagnostics;
+using Foundatio.Repositories.Elasticsearch.CustomFields;
using Foundatio.Repositories.Models;
namespace Exceptionless.Core.Models;
[DebuggerDisplay("Id: {Id}, Type: {Type}, Date: {Date}, Message: {Message}, Value: {Value}, Count: {Count}")]
-public class PersistentEvent : Event, IOwnedByOrganizationAndProjectAndStackWithIdentity, IHaveCreatedDate
+public class PersistentEvent : Event, IOwnedByOrganizationAndProjectAndStackWithIdentity, IHaveCreatedDate, IHaveVirtualCustomFields
{
///
/// Unique id that identifies an event.
@@ -39,5 +40,15 @@ public class PersistentEvent : Event, IOwnedByOrganizationAndProjectAndStackWith
///
/// Used to store primitive data type custom data values for searching the event.
///
- public DataDictionary Idx { get; set; } = new();
+ public IDictionary Idx { get; set; } = new DataDictionary();
+
+ object? IHaveVirtualCustomFields.GetCustomField(string name) => Data?[name];
+ IDictionary IHaveVirtualCustomFields.GetCustomFields() => Data ?? [];
+ void IHaveVirtualCustomFields.RemoveCustomField(string name) => Data?.Remove(name);
+ void IHaveVirtualCustomFields.SetCustomField(string name, object value)
+ {
+ Data ??= new DataDictionary();
+ Data[name] = value;
+ }
+ string IHaveVirtualCustomFields.GetTenantKey() => OrganizationId;
}
diff --git a/src/Exceptionless.Core/Repositories/Configuration/ExceptionlessElasticConfiguration.cs b/src/Exceptionless.Core/Repositories/Configuration/ExceptionlessElasticConfiguration.cs
index e8eaa7e37e..a23ac9fa12 100644
--- a/src/Exceptionless.Core/Repositories/Configuration/ExceptionlessElasticConfiguration.cs
+++ b/src/Exceptionless.Core/Repositories/Configuration/ExceptionlessElasticConfiguration.cs
@@ -45,6 +45,7 @@ ILoggerFactory loggerFactory
AddIndex(Tokens = new TokenIndex(this));
AddIndex(Users = new UserIndex(this));
AddIndex(WebHooks = new WebHookIndex(this));
+ AddCustomFieldIndex(_appOptions.ElasticsearchOptions.ScopePrefix + "customfields", appOptions.ElasticsearchOptions.NumberOfReplicas);
}
public Task RunAsync(CancellationToken shutdownToken = default)
diff --git a/src/Exceptionless.Core/Repositories/Configuration/Indexes/EventIndex.cs b/src/Exceptionless.Core/Repositories/Configuration/Indexes/EventIndex.cs
index 725bd7672b..eab8d9ed0b 100644
--- a/src/Exceptionless.Core/Repositories/Configuration/Indexes/EventIndex.cs
+++ b/src/Exceptionless.Core/Repositories/Configuration/Indexes/EventIndex.cs
@@ -21,6 +21,8 @@ public sealed class EventIndex : DailyIndex
public EventIndex(ExceptionlessElasticConfiguration configuration, IServiceProvider serviceProvider, AppOptions appOptions) : base(configuration, configuration.Options.ScopePrefix + "events", 1, doc => ((PersistentEvent)doc).Date.UtcDateTime)
{
+ AddStandardCustomFieldTypes();
+
_configuration = configuration;
_serviceProvider = serviceProvider;
@@ -46,12 +48,6 @@ public override TypeMappingDescriptor ConfigureIndexMapping(Typ
{
var mapping = map
.Dynamic(false)
- .DynamicTemplates(dt => dt
- .DynamicTemplate("idx_bool", t => t.Match("*-b").Mapping(m => m.Boolean(s => s)))
- .DynamicTemplate("idx_date", t => t.Match("*-d").Mapping(m => m.Date(s => s)))
- .DynamicTemplate("idx_number", t => t.Match("*-n").Mapping(m => m.Number(s => s.Type(NumberType.Double))))
- .DynamicTemplate("idx_reference", t => t.Match("*-r").Mapping(m => m.Keyword(s => s.IgnoreAbove(256))))
- .DynamicTemplate("idx_string", t => t.Match("*-s").Mapping(m => m.Keyword(s => s.IgnoreAbove(1024)))))
.Properties(p => p
.SetupDefaults()
.Keyword(f => f.Name(e => e.Id))
@@ -74,7 +70,6 @@ public override TypeMappingDescriptor ConfigureIndexMapping(Typ
.Scalar(f => f.Count)
.Boolean(f => f.Name(e => e.IsFirstOccurrence))
.FieldAlias(a => a.Name(Alias.IsFirstOccurrence).Path(f => f.IsFirstOccurrence))
- .Object