Skip to content

Commit

Permalink
Elasticsearch geo location type addition (#16880)
Browse files Browse the repository at this point in the history
Co-authored-by: Hisham Bin Ateya <hishamco_2007@yahoo.com>
  • Loading branch information
PBMikeW and hishamco authored Oct 17, 2024
1 parent 99c8b77 commit b9bbef1
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,17 @@ await _elasticClient.MapAsync<string>(p => p
)
)
);
// DynamicTemplates mapping for Geo fields, the GeoPointFieldIndexHandler adds a Location index by default.
await _elasticClient.MapAsync<object>(p => p
.Index(fullIndexName)
.DynamicTemplates(d => d
.DynamicTemplate("*.Location", dyn => dyn
.MatchMappingType("object")
.PathMatch("*" + ".Location")
.Mapping(m => m.GeoPoint(g => g))
)
)
);

return response.Acknowledged;
}
Expand Down Expand Up @@ -1028,6 +1039,13 @@ private static Dictionary<string, object> 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;
}
}
Expand Down

0 comments on commit b9bbef1

Please sign in to comment.