美好的一天:
我正在尝试一次加载父母和孩子。我的查询是这样:
ISearchResponse<Models.Facilities.Facility> response = await this._elasticClient.SearchAsync<Models.Facilities.Facility>(s =>
s.Query(q => (q.GeoDistance(g => g.Boost(1.1)
.Field(f => f.BusinessLocation)
.DistanceType(GeoDistanceType.Arc)
.Distance(search.location.distance.ToString() + "m")
.Location((double)search.location.latitude, (double)search.location.longitude)
)
&&
q.HasChild<Models.Facilities.FacilityType>(c => c.Query(qq => qq.MatchAll()).Name("FacilityType")))
||
q.GeoDistance(g => g.Boost(1.1)
.Field(f => f.ServiceAreas)
.DistanceType(GeoDistanceType.Arc)
.Distance(search.location.distance.ToString() + "m")
.Location((double)search.location.latitude, (double)search.location.longitude))
)
.Aggregations(a =>
a.Children<Models.Facilities.FacilityType>("Capacity", child => child.Aggregations(ca => ca.Histogram("Capacity",
h => h.Field(p => p.Capacity)
.Interval(10)
.Missing(0))))
.Histogram("Distance", d => d.Field(f => f.BusinessLocation)
.Interval(10)
.Order(HistogramOrder.CountDescending)))
.Sort(g => g.GeoDistance(g => g.Field(f => f.BusinessLocation)
.DistanceType(GeoDistanceType.Arc)
.Order(SortOrder.Descending)
.Unit(DistanceUnit.Miles)).GeoDistance(g => g.Field(f => f.ServiceAreas)
.DistanceType(GeoDistanceType.Arc)
.Order(SortOrder.Descending))));
设施和 FacilityType 从父文档 扩展而来。我正在尝试加载父Facility
及其子FacilityType
。本质上来说,如果我可以实现像这样的facilityObj.facilityTypes
对象。让我知道是否可行。
答案 0 :(得分:0)
InnerHits适用于嵌套关系和父/子关系。