diff --git a/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Services/ElasticIndexManager.cs b/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Services/ElasticIndexManager.cs index 7d422e27723..f6a1ea5256e 100644 --- a/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Services/ElasticIndexManager.cs +++ b/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Services/ElasticIndexManager.cs @@ -546,6 +546,17 @@ await _elasticClient.MapAsync(p => p ) ) ); + // DynamicTemplates mapping for Geo fields, the GeoPointFieldIndexHandler adds a Location index by default. + await _elasticClient.MapAsync(p => p + .Index(fullIndexName) + .DynamicTemplates(d => d + .DynamicTemplate("*.Location", dyn => dyn + .MatchMappingType("object") + .PathMatch("*" + ".Location") + .Mapping(m => m.GeoPoint(g => g)) + ) + ) + ); return response.Acknowledged; } @@ -1028,6 +1039,13 @@ private static Dictionary CreateElasticDocument(DocumentIndex do AddValue(entries, entry.Name, stringValue); } } + break; + case DocumentIndex.Types.GeoPoint: + if (entry.Value is DocumentIndex.GeoPoint point) + { + AddValue(entries, entry.Name, new GeoLocation((double)point.Latitude, (double)point.Longitude)); + } + break; } }