# Querying dense\_vector from the High Level REST Java API

**URL:** <https://discuss.elastic.co/t/querying-dense-vector-from-the-high-level-rest-java-api/244956>\
**Category:** Elasticsearch\
**Created:** [August 14, 2020, 12:03am UTC](https://discuss.elastic.co/t/querying-dense-vector-from-the-high-level-rest-java-api/244956 "2020-08-14T00:03:33Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![MJB](https://avatars.discourse-cdn.com/v4/letter/m/ea666f/32.png) [@MJB](https://discuss.elastic.co/u/MJB)\
**Post date:** [August 15, 2020, 3:28pm UTC](https://discuss.elastic.co/t/querying-dense-vector-from-the-high-level-rest-java-api/244956/4 "2020-08-15T15:28:05Z")

</div>

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](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)
```

---

_[View the full topic](https://discuss.elastic.co/t/querying-dense-vector-from-the-high-level-rest-java-api/244956)._
