i trying create function_score elasticsearch query using nest (gauss function), , have geo point object pass 'origin', "origin" method in nest accepts string, result elasticsearch can't parse query. how can write query in nest elasticsearch can parse correctly?
var originloc = jsonconvert.serializeobject(userlocation.geocenter); var searchdesc = new searchdescriptor<mycustomtype>().query(q => q.functionscore(fs => fs.functions(func => func.gauss("geocenter", gs => gs.origin(originloc).offset("1km").scale("500m").decay(0.99))))); nest passes code above elasticsearch this, elasticsearch can't parse (origin parsed string).
"query": { "function_score": { "functions": [ { "gauss": { "geocenter": { "origin": "{\"lat\":29.745703,\"lon\":-95.740514}", //<-- string "scale": "500m", "offset": "1km", "decay": 0.99 } } } ] } }
below correct query elasticsearch can run (origin parsed geo point object)
"query": { "function_score": { "functions": [ { "gauss": { "geocenter": { "origin": { //<----- geo point serialized object "lon": -95.740514, "lat": 29.745703 }, "scale": "500m", "offset": "1km", "decay": 0.99 } } } ] }
i have in code
.query(f => f .functionscore(fs => fs .boostmode(functionboostmode.sum) .functions(ff => ff .linear("location", d => d.origin(origin).scale("8km").decay(0.33)) ) ) ) where origin -> var origin = object.latitude + "," + object.longitude;
Comments
Post a Comment