-->

如何订购使用集合(Edm.GeographyPoint)时,在文件上的距离文档(How to ord

2019-10-29 12:21发布

我有不同的产品的指标。 每个产品在许多商店。 该指数的一个字段是一个集合(Edm.GeographyPoint)至极持有该产品可在商店的坐标。

一些示例数据 (CSV)that's导入在指数:

"product","vendor","coordinates"
"Coca Cola 0.5l","Billa","[{ ""type"": ""Point"", ""coordinates"": [48.1184669,16.2030506]},{ ""type"": ""Point"", ""coordinates"": [48.1184977,16.1877297]},{ ""type"": ""Point"", ""coordinates"": [48.1340644,16.2809381]}]"
"Nöm Mix Joghurt 250mg","Billa","[{ ""type"": ""Point"", ""coordinates"": [48.1184669,16.2030506]},{ ""type"": ""Point"", ""coordinates"": [48.1184977,16.1877297]},{ ""type"": ""Point"", ""coordinates"": [48.1340644,16.2809381]}]"
"Red Bull Dose 250ml","Billa","[{ ""type"": ""Point"", ""coordinates"": [48.1184669,16.2030506]},{ ""type"": ""Point"", ""coordinates"": [48.1184977,16.1877297]},{ ""type"": ""Point"", ""coordinates"": [48.1340644,16.2809381]}]"

现在,我想距离查询的结果进行排序。

搜索查询

search=red bull&$count=true&$orderby=geo.distance(coordinates, geography'POINT(48.1078023 16.1692154)') asc

这工作正常,如果我有一个地理点的每个数据集,但只要it'sa点我收到以下错误收集:

"Invalid expression: The argument for an invocation of a function with name 'geo.distance' is not a single value. All arguments for this function must be single values.\r\nParameter name: $orderby"

我的问题是,如果有另一个地球的功能,让我为了用点数据集在收集,或者如果我必须使用另一种模式为我的数据结构。

Answer 1:

有没有办法在Azure中搜索收集领域,包括地理点的字段进行排序。

需要怎么做才能使这是某种方式聚集在集合场产生要在其上进行排序每个文档的单个值。 例如,如果你想通过数字集合进行排序,你就必须选择是否排序的平均值,最小值,最大值,总和,或其他一些聚合函数。 这是不太清楚你想要的地理空间坐标的集合什么的聚集。

由于Azure的搜索不支持在排序过程中收集汇总的概念,它是不可能在今天的收藏文档进行排序。 如果你的目标是到商店,而不是产品,其中每个店铺都有一个地理位置进行排序,那么我建议创建存储第二索引。



文章来源: How to order documents by distance when using Collection(Edm.GeographyPoint) on the documents