# How to covert this elastic search functional score query to java API using ES 2.3.3

**URL:** <https://discuss.elastic.co/t/how-to-covert-this-elastic-search-functional-score-query-to-java-api-using-es-2-3-3/99161>\
**Category:** Elasticsearch\
**Created:** [September 1, 2017, 6:29pm UTC](https://discuss.elastic.co/t/how-to-covert-this-elastic-search-functional-score-query-to-java-api-using-es-2-3-3/99161 "2017-09-01T18:29:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![thejavamonk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thejavamonk/32/21765_2.png) [@thejavamonk](https://discuss.elastic.co/u/thejavamonk)\
**Post date:** [September 1, 2017, 6:29pm UTC](https://discuss.elastic.co/t/how-to-covert-this-elastic-search-functional-score-query-to-java-api-using-es-2-3-3/99161/1 "2017-09-01T18:29:07Z")

</div>

```
GET /schema_name/_search
 {
  "from": 0,
  "size": 200,
  "query": {
     "function_score": {
     "query": {
        "match_all": {}
    },
    "boost": "5",
    "functions": [{
            "filter": {
                "term": {
                    "alert_code": "event_rule_1"
                }
            },
            "weight": 50
        },
        {
            "filter": {
                "term": {
                    "alert_code": "event_rule_2"
                }
            },
            "weight": 30
        },
        {
            "filter": {
                "term": {
                    "alert_code": "event_rule_3"
                }
            },
            "weight": 10
        },
        {
            "filter": {
                "term": {
                    "alert_code": "event_rule_4"
                }
            },
            "weight": 10
        },
        {
            "filter": {
                "term": {
                    "alert_code": "event_rule_5"
                }
            },
            "weight": 50
        },
        {
            "filter": {
                "term": {
                    "alert_code": "event_rule_6"
                }
            },
            "weight": 50
        }
    ],
    "max_boost": 50,
    "score_mode": "max",
    "boost_mode": "replace",
    "min_score": 0
     }
   }
 }

```

Have been able to reach to this point

FunctionScoreQueryBuilder functionScoreQueryBuilder = QueryBuilders  
.functionScoreQuery(queryBuilder)  
.setMinScore(0f)  
.maxBoost(50f)  
.scoreMode("max")  
.boostMode(CombineFunction.REPLACE);

But not sure about how to add the functions and filters ☹

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 29, 2017, 6:29pm UTC](https://discuss.elastic.co/t/how-to-covert-this-elastic-search-functional-score-query-to-java-api-using-es-2-3-3/99161/2 "2017-09-29T18:29:10Z")

</div>

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