Can this query be optimized?

I'm interested in any optimizations, but in particular, I want to ensure the score functions are only executed on documents that match at least one of the should clauses, not on all documents. Not sure whether that is the case as it is written now:

{
  "body": {
    "query": {
      "function_score": {
        "functions": [
          ...a bunch of functions
        ],
        "boost_mode": "replace",
        "query": {
          "bool": {
            "should": [
              {
                "match_phrase": {
                  "field 1": "query"
                }
              },
              {
                "match_phrase": {
                  "field 2": "query"
                }
              },
              {
                "match_phrase": {
                  "field 3": "query"
                }
              }
            ]
          }
        }
      }
    }
  }
}

Elasticsearch >=2.1, in case it makes a difference.

Your query is correct: the functions will only be evaluated on documents that match at least one of those should clauses (because you only have should clauses, at least one must match to be considered a hit).

The query section of the function_score is essentially a gatekeeper: only documents that match the query are subsequently scored by the functions. Each function can have it's own filter as well, to further limit what functions are applied to which documents/values.