Azure Search Indexer cannot retrieve a GeographyPoint filed from a document in DocumentDB
尝试索引存储在documentdb集合中的文档时出现问题。
索引器的数据源是用自定义SQL定义的,以检索更改的文档。我要索引的文档有一个名为
尝试创建索引器时出现的错误是:
列"locationgp"的类型jobject与索引中edm.geographypoint类型的字段不兼容。
有什么想法吗?
这是数据源的定义:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | return new DataSource() { Name ="opportunities-datasource", Container = new DataContainer() { Name ="Companies", Query = @"SELECT o.id, o.CompanyName, o.LocationGP, o.Location.CityName AS LocationCity, o.Location.StateName AS LocationState, o.Location.CountryName AS LocationCountry, o._ts FROM Companies o WHERE o.DocType = 1 AND o._ts > @HighWaterMark" }, Type ="documentdb", Credentials = new DataSourceCredentials() { ConnectionString = String.Format("AccountEndpoint={0};AccountKey={1};Database=CompaniesDb", DocumentDbEndpointUri, DocumentDbPrimaryKey) }, DataChangeDetectionPolicy = new HighWaterMarkChangeDetectionPolicy("_ts"), DataDeletionDetectionPolicy = new SoftDeleteColumnDeletionDetectionPolicy("Status","2") }; |
这是文件:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | [{ "id":"088e1e97-6d59-40ad-a9be-620fdc7938c7", "CompanyName":"Neptune", "LocationGP": { "Latitude": 39.8010482788086, "Longitude": -89.6436004638672, "IsEmpty": false, "Z": null, "M": null, "CoordinateSystem": { "EpsgId": 4326, "Id":"4326", "Name":"WGS84" } }, "Location": { "CityName":"Springfield", "CountryName":"US", "StateName":"IL" }, "Status": 1, "DocType": 1, "Timestamp":"2016-08-19T16:08:46.0481948Z", "_ts": 1471622922 }] |
号
下面是关于Azure Search的另外两个文档,解释了接受的地理实例类型:
- https://msdn.microsoft.com/en-us/library/azure/dn798938.aspx
- https://msdn.microsoft.com/en-us/library/azure/dn946880.aspx?F=255&;mspperror=-2147217396
基本上,它需要采用geojson的"点"类型格式。
问题是,
为了使它工作,我刚刚创建了一个名为
1 2 3 4 5 6 7 8 9 10 11 | public class EdmGeographyPoint { public EdmGeographyPoint(double longitude, double latitude) { coordinates = new double[] { longitude, latitude }; type ="Point"; } public string type { get; private set; } public double[] coordinates { get; private set; } } |
然后我将locationgp属性的类型替换为edmlocation。
也许有一个更好的解决方案,但是文档对于这个主题来说是混乱的:https://azure.microsoft.com/en-us/documentation/articles/search-howto-dotnet-sdk/