Changing the score of the results based on a field's value [Java]

I am trying to change the order of the results based on a keyword field.

something similar to this but with the java client.

{
   "query": {
      "function_score": {
         "functions": [
             {
               "field_value_factor" : {
                    "field" : "applicationDate",
                    "factor" : 0.001
               }
             },
            {
               "filter": {
                  "term": {
                     "status": "available"
                  }
               },
               "weight": 360
            },
            {
               "filter": {
                  "term": {
                     "status": "progress"
                  }
               },
               "weight": 180
            }
         ],
         "boost_mode": "multiply",
         "score_mode": "sum"
      }
   }
}

The project is based on elastic 5.6

so far the normal query looks like this

query4QueryBuilder
                .should(QueryBuilders.matchQuery(String.format("name.%s.raw", language), query).boost(200)
                        .analyzer("search_raw"))
                .should(QueryBuilders.matchQuery(String.format("collector.%s.raw", language), query).boost(100)
                        .analyzer("search_raw"))

and the keyword field i would like to sort on is called osm_value .
any help is welcome.
Thank you

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.