Merge a8129fde5ae8060f695c39afc58be1469be1dbf7 into 49a92fc25e9dab2ffe10380889ca01b8b21cb557
This commit is contained in:
		
						commit
						19bc0c5daf
					
				@ -518,3 +518,45 @@ func (q TermsSetQuery) Map() map[string]interface{} {
 | 
				
			|||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// geoFilterParams represents a query of type "geo_distance", as described in:
 | 
				
			||||||
 | 
					// https://www.elastic.co/guide/en/elasticsearch/reference/7.17/query-dsl-geo-distance-query.html
 | 
				
			||||||
 | 
					type GeoFilter struct {
 | 
				
			||||||
 | 
						params geoFilterParams
 | 
				
			||||||
 | 
						filed  string
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func GeoFilterFunc(distance string, MiddleCentroid []float64, filed string) *GeoFilter {
 | 
				
			||||||
 | 
						return &GeoFilter{
 | 
				
			||||||
 | 
							params: geoFilterParams{
 | 
				
			||||||
 | 
								Distance:       distance,
 | 
				
			||||||
 | 
								MiddleCentroid: MiddleCentroid,
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
							filed: filed,
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type geoFilterParams struct {
 | 
				
			||||||
 | 
						Distance       string    `structs:"distance,omitempty"`
 | 
				
			||||||
 | 
						MiddleCentroid []float64 `structs:"location,omitempty"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (g *GeoFilter) Distance(distance string) *GeoFilter {
 | 
				
			||||||
 | 
						g.params.Distance = distance
 | 
				
			||||||
 | 
						return g
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					func (g *GeoFilter) MiddleCentroid(middleCentroid []float64) *GeoFilter {
 | 
				
			||||||
 | 
						g.params.MiddleCentroid = middleCentroid
 | 
				
			||||||
 | 
						return g
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (g *GeoFilter) Map() map[string]interface{} {
 | 
				
			||||||
 | 
						m := structs.Map(g.params)
 | 
				
			||||||
 | 
						m[g.filed] = m["location"]
 | 
				
			||||||
 | 
						delete(m, "location")
 | 
				
			||||||
 | 
						response := map[string]interface{}{
 | 
				
			||||||
 | 
							"geo_distance": m}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return response
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user