我试图在公共传输算法中实现Elasticsearch来获取GTFS数据,但不知道获取所需数据的“最佳”方法是什么(注意:我在C#中使用NEST )。
我编制了两个类别的索引:
public class StopTimes : IGTFS
{
public string trip_id;
public string arrival_time;
public string departure_time;
public string stop_id;
public string stop_sequence;
public string stop_headsign;
public string shape_dist_traveled;
}
public class Trips : IGTFS
{
public string route_id;
public string service_id;
public string trip_id;
public string trip_head_sign;
public string trip_short_name;
public string direction_id;
public string shape_id;
}我想知道如何从stop_id中获得一个简单请求中的所有对应的route_id (一个停止可以属于多个路由)。
目前,我试图用两个步骤来完成这个任务,因为它可以在几个stop_id中匹配,几个trip_id属于单个route_id (对于8个route_id,我有6k trip_id)。
StopTimes (超过2k点击)数据,stop_id匹配。
_client.Search(s => s .Index("gtfs_data") .Type(“gtfs_data”) .Fields("trip_id") .Query(q => Q .Term("stop_id",id).Size(10000000) );route_id,但我不知道如何继续(方面?)
result2 = _client.Search(s => s .Index(_ratpData) .Query(q => q .Terms(t => t.trip_id,terms)) //terms =数组stop_id .FacetTerm(t=>t .OnField(f=>f.route_id).Size(10000000) );谢谢你的帮助:)
发布于 2013-08-06 09:11:09
如果您的数据是这样建立索引的,听起来您的第一个查询也需要是一个方面--您想要一个stop_id的所有stop_id,所以您需要trip_id上的一个方面(而不是返回所有实际的停止时间)。然后,与您指定的一样,下一个查询是route_id上的一个方面。确保将搜索类型设置为计数以提高性能(http://www.elasticsearch.org/guide/reference/api/search/search-type/)。
如果trip_id始终属于单个route_id,则另一个选项是在Trips和StopTimes之间使用父子关系。您将Trip设置为映射中的StopTime的父级(http://www.elasticsearch.org/guide/reference/mapping/parent-field/),对每个停止时间进行索引,并以trip作为其父时间,然后可以使用has_child查询或筛选器(http://www.elasticsearch.org/guide/reference/query-dsl/has-child-query/)为某个stop_id带来所有Trips (route_ids)。
https://stackoverflow.com/questions/18065707
复制相似问题