oct
oct

Reputation: 5

Azure Cognitive Search - Error using GeographyPoint

Using Azure Cognitive Search and specifying a GeographyPoint field like this:

[SearchableField(IsFilterable = true, IsSortable = true)]
public GeographyPoint geoPoint { get; set; }

And them initializing it like this:

double lat = ... 
double lng = ...
doc.geoPoint = GeographyPoint.Create(lat, lng);

Returns the error (when the method CreateOrUpdateIndex is used):

Azure.RequestFailedException: 'The request is invalid. Details: definition : The searchable field 'geoPoint' must be of type Edm.String or Collection(Edm.String).

The documentation says that the type Edm.GeographyPoint is supported. Anyone knows the reason for this error?

We already read this question, and our implementation seens right. We are using Azure Cognitive Search SDK 11.

We expected that the creation of the index would work with the GeographyPoint field. We read the documentation and review our approach and found no error in our implementation.

Upvotes: 0

Views: 119

Answers (1)

Gaurav Mantri
Gaurav Mantri

Reputation: 136306

Edm.GeographyPoint data type is supported however a field of this data type is not searchable. Only fields with Edm.String and Collection(Edm.String) data types are searchable. This is why you are getting this error.

Note that searchable indicates whether it's usable for full-text search. Even though point fields cannot be searchable, you can still mark them as filterable and/or sortable and use them for geo-filters (e.g. distance or bounding box predicates) or for sorting.

Please see REST API documentation here: https://learn.microsoft.com/en-us/rest/api/searchservice/create-index#-field-definitions-.

To fix the error, make this field non-searchable.

Upvotes: 1

Related Questions