Querying dense_vector from the High Level REST Java API

Update
trying the approach shown here although I'd prefer to use just the Java API https://discuss.elastic.co/t/cannot-set-up-script-score-for-dense-vector-using-java-rest-api/238849/3. This gets executed but all scores are 1.0 - only the match_all query gets executed. What I'm doing wrong?

  SearchTemplateRequest request = new SearchTemplateRequest();
    request.setRequest(searchRequest);
    request.setScriptType(ScriptType.INLINE);


    def script =
            "{ \"query\":   " +
                    "{" +
                    "    \"script_score\": {       " +
                    "        \"query\": { " +
                    "           \"query_string\" : { " +
                    "               \"query\" : \"" + "match_all" + "\", " +
                    "                : \"{}\" " +
                    "            }  " +
                    "        },   " +
                    "        \"script\": { " +
                    "            \"source\": \"cosineSimilarity( " + vectors+ ",'title_vector') + 1.0\"  " +
                    "        } " +
                    "    }  " +
                    "}" +
                    "}  ";
    request.setScript(script);
    SearchResponse s = elastic.search(request.getRequest(), RequestOptions.DEFAULT)