title: how to write elasticsearch script_score in java api
body: <p>I find a function in ElasticSearch like</p>
  
  <pre><code>GET /_search
  {
    "function_score": {
      "functions": [
        { ...location clause... }, 
        { ...price clause... }, 
        {
          "script_score": {
            "params": { 
              "threshold": 80,
              "discount": 0.1,
              "target": 10
            },
            "script": "price  = doc['price'].value; margin = doc['margin'].value;
            if (price &lt; threshold) { return price * margin / target };
            return price * (1 - discount) * margin / target;" 
          }
        }
      ]
    }
  }
  </code></pre>
  
  <ul>
  <li>I use <code>ScoreFunctionBuilder</code> to achive the "location caluse" and
  "price caluse" ,but I do not know how to write <code>"script_score"</code> and <code>"script"</code> by java api</li>
  <li>The ES version in my project is 2.2.0 and I use the
  java api to achieve this function</li>
  <li>But I can not find the API like 
  <code>ScriptScoreFunctionBuilder. scriptFunction(String script,
  Map&lt;String, Object&gt; params)</code> how can I do？  Thx :)
  <br></li>
  <li>Finally I figure out how to write it by using JD-JUI to check the "elasticsearch.jar" file.</li>
  </ul>
  
  <p>EX:</p>
  
  <pre><code>Map&lt;String, Object&gt; params = new HashMap&lt;&gt;();
      params.put("num1", 10);
      params.put("num2", 4);
  
      String inlineScript = "doc['score'].value * num1 * num2";
  
      Script script = new Script(script, ScriptType.INLINE, "groovy", params);
  
      ScriptScoreFunctionBuilder scriptBuilder = ScoreFunctionBuilders.scriptFunction(ss);
  </code></pre>
  
  <p>that's all  </p>