Using GeoPoint Fields

 

The GeoPoint is a Hawksearch data type that holds a pair of latitude/longitude values.
A special class was created to represent this data type named GeoPoint. This class has 2 constructors - one for passing the latitude/longitude as double values, one for passing the latitude/longitude as strings

public GeoPoint(double latitude, double longitude) public GeoPoint(string latitude, string longitude)


Example of introducing the GeoPoint for indexing in a custom pipe:

public class LocationItemPageAttributesPipe : IPipe<IPageIndexingCommand<LocationItemPage>> { public int Order => 360; public string Name => "Location Page Attributes"; private readonly IUrlResolver _urlResolver; public LocationItemPageAttributesPipe(IUrlResolver urlResolver) { _urlResolver = urlResolver; } public void Execute(IPageIndexingCommand<LocationItemPage> command) { foreach (var entry in command.Entries) { var contentItem = entry.OutputEntry; var page = entry.InputEntry; contentItem.Attributes["ImageUrl"] = new List<string> { _urlResolver.GetUrl(page.Image) }; contentItem.Attributes["Description"] = new List<string> { page.MainIntro }; contentItem.Attributes["coordinates"] = new List<GeoPoint> { new GeoPoint(page.Latitude, page.Longitude) }; } } }

 

Troubleshooting

If you happen to receive from Hawksearch the message (also displayed in the Indexing Jobs' logs)

Incorrect input format. It's not allowed to use nested objects.

you might want to lowercase the name of the sent attribute. For instance, if you have

change it to:

even though in the Hawksearch engine your field might be defined as “Coordinates” with capital “C”.