# Function score, script and JAVA API

**URL:** <https://discuss.elastic.co/t/function-score-script-and-java-api/86632>\
**Category:** Elasticsearch\
**Created:** [May 22, 2017, 9:00am UTC](https://discuss.elastic.co/t/function-score-script-and-java-api/86632 "2017-05-22T09:00:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![redhelling21](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/redhelling21/32/16605_2.png) [@redhelling21](https://discuss.elastic.co/u/redhelling21)\
**Post date:** [May 22, 2017, 9:00am UTC](https://discuss.elastic.co/t/function-score-script-and-java-api/86632/1 "2017-05-22T09:00:19Z")

</div>

Hi,

I am quite new with the Java API, and I am trying to "translate" a request to this API :

```
POST /real_customers_5000/_search
{
   "size": 1000,
   "min_score": 0.1,
   "query": {
      "function_score": {
         "query": {
            "bool": {
               "should": [
                  {
                     "term": {
                        "BIRTH_DATE": "06/06/1971"
                     }
                  },
                  {
                     "term": {
                        "BIRTH_DATE": ""
                     }
                  }
               ],
               "minimum_should_match": 1
            }
         },
         "functions": [
            {
               "script_score": {
                  "script": {
                     "inline": "my_script",
                     "lang": "native",
                     "params": {
                        "fields": [
                           
                           {
                              "field": "MAIL_PERS",
                              "value": "jccouvy@yahoo.fr",
                              "cleaners": [
                                 {
                                    "name": "no.priv.garshol.duke.cleaners.RegexpCleaner",
                                    "params": {
                                       "regexp": "^([a-z0-9]+(?:[._-][a-z0-9]+)*)@([a-z0-9]+(?:[.-][a-z0-9]+)*\\.[a-z]{2,})$"
                                    }
                                 }
                              ],
                              "high": 0.838648094381669,
                              "comparator": {
                                 "name": "no.priv.garshol.duke.comparators.Levenshtein"
                              },
                              "low": 0.32794743090493866
                           },
                           {
                              "field": "BIRTH_DATE",
                              "value": "06/06/1971",
                              "cleaners": [
                                 {
                                    "name": "no.priv.garshol.duke.cleaners.LowerCaseNormalizeCleaner"
                                 }
                              ],
                              "high": 0.82,
                              "comparator": {
                                 "name": "no.priv.garshol.duke.comparators.ExactComparator"
                              },
                              "low": 0.0
                           }
                        ]
                     }
                  }
               }
            }
         ]
      }
   }
}

```

Of course, I tried searching on google and in the forum, but the results are either outdated or too different.  
This request uses [this plugin](https://github.com/YannBrrd/elasticsearch-entity-resolution) (which I adapted for ES 5.4). I hope someone could find a solution...  
Thanks in advance !

---

<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:** [June 19, 2017, 9:00am UTC](https://discuss.elastic.co/t/function-score-script-and-java-api/86632/2 "2017-06-19T09:00:30Z")

</div>

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