Elasticsearch Java API Function Score Query with geo and time gauss function -


i trying build function score query java api of elasticsearch:

{    "query": {       "function_score": {          "functions": [             {                "gauss": {                   "location": {                      "origin": {                         "lat": 52.55,                         "lon": 13.69                      },                      "offset": "30km",                      "scale": "10km",                      "decay": 0.9                   }                }             },             {                "gauss": {                   "createdat": {                      "origin": "2015-06-14t15:50:00",                      "scale": "8h",                      "offset": "4h",                      "decay": 0.75                   }                }             }          ]       }    } } 

but can't find documentation regarding java api , function score queries. have far:

elasticsearch.client   .preparesearch(config.offerindex.value)   .setquery(      querybuilders.functionscorequery(        scorefunctionbuilders          .gaussdecayfunction("location", ???, ???).setdecay(0.9)      )   ) 

the second , third parameter of gaussdecayfunction named origin , scale. have type , have no idea how have provide location , time values there. , next question how can provide functions in functionscore builder

i have found solution not sure if clean way it. appreciate if can approve it.

val lat = 52.52 val lon = 13.402  querybuilders   .functionscorequery(      scorefunctionbuilders.gaussdecayfunction("location", new geopoint(lat, lon), "10km")        .setdecay(0.9)        .setoffset("30km"))   .add(      scorefunctionbuilders.gaussdecayfunction("createdat", new datetime(), "8h")        .setdecay(0.75)        .setoffset("4h")) ) 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -