# Hybrid Search Java Api not returning Rank

**URL:** <https://discuss.elastic.co/t/hybrid-search-java-api-not-returning-rank/360700>\
**Category:** Elasticsearch\
**Tags:** language-clients, vector-search\
**Created:** [June 3, 2024, 9:48am UTC](https://discuss.elastic.co/t/hybrid-search-java-api-not-returning-rank/360700 "2024-06-03T09:48:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tommaso\_FAVARON](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tommaso_favaron/32/123162_2.png) [@Tommaso\_FAVARON](https://discuss.elastic.co/u/Tommaso_FAVARON)\
**Post date:** [June 3, 2024, 9:48am UTC](https://discuss.elastic.co/t/hybrid-search-java-api-not-returning-rank/360700/1 "2024-06-03T09:48:20Z")

</div>

Hello.  
I want to perform hybrid search using java client.  
With elasticsarch-java 8.11 environment, this is my query:

```auto
SearchResponse<Map> response = esClient.search(s -> s
                .index(index)
                .size(size)
                .query(boolQuery._toQuery())
                .knn(knnQuery)
                .rank(rn->rn.rrf(rrfb->rrfb.rankConstant(20L).windowSize((long) 10))),
                Map.class);

```

the problem that i have is that **response** don't contain any field that indicate the **rank** of the search.  
Is this as inteded , so that the rank is the index of the response?

---

<div class="post-metadata">

**Author:** ![joemcelroy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joemcelroy/32/103757_2.png) [@joemcelroy](https://discuss.elastic.co/u/joemcelroy)\
**Post date:** [June 4, 2024, 12:29pm UTC](https://discuss.elastic.co/t/hybrid-search-java-api-not-returning-rank/360700/2 "2024-06-04T12:29:40Z")

</div>

Yes the rank is in order of the response. The rank is also specified in the `_rank` field. Using RRF, both sets of results are merged into a single result set and ranked accordingly.

One thing to note, we don't provide a score for each result but provide a meta rank field in the response only.

See this doc for more information [Reciprocal rank fusion | Elasticsearch Guide [8.13] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/rrf.html)

Joe

---

<div class="post-metadata">

**Author:** ![Tommaso\_FAVARON](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tommaso_favaron/32/123162_2.png) [@Tommaso\_FAVARON](https://discuss.elastic.co/u/Tommaso_FAVARON)\
**Post date:** [June 5, 2024, 3:21pm UTC](https://discuss.elastic.co/t/hybrid-search-java-api-not-returning-rank/360700/3 "2024-06-05T15:21:30Z")

</div>

Hi, thank you @joemcelroy, of course using rest Api i see that the response also include the rank,  
my problem is when i perform the query with co.elastic.clients library in Java, that the response not include the rank field.  
Hope I have explained my problem well,  
Thanks,

Tommaso

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 5, 2024, 3:41pm UTC](https://discuss.elastic.co/t/hybrid-search-java-api-not-returning-rank/360700/4 "2024-06-05T15:41:32Z")

</div>

Did you try with a more recent version of the client?  
I did not check myself yet but this might have been fixed since then.

---

<div class="post-metadata">

**Author:** ![Tommaso\_FAVARON](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tommaso_favaron/32/123162_2.png) [@Tommaso\_FAVARON](https://discuss.elastic.co/u/Tommaso_FAVARON)\
**Post date:** [June 6, 2024, 9:56am UTC](https://discuss.elastic.co/t/hybrid-search-java-api-not-returning-rank/360700/5 "2024-06-06T09:56:41Z")

</div>

Hi @dadoonet, no also in new version of java Library i can't see the rank.  
last tested 8.13.3

Thanks,  
Tommaso.

---

<div class="post-metadata">

**Author:** ![ltrotta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ltrotta/32/124003_2.png) [@ltrotta](https://discuss.elastic.co/u/ltrotta)\
**Post date:** [June 6, 2024, 5:31pm UTC](https://discuss.elastic.co/t/hybrid-search-java-api-not-returning-rank/360700/6 "2024-06-06T17:31:54Z")

</div>

Hello! We seem to be missing the field from the client, if you want you can open an issue on our [github repo](https://github.com/elastic/elasticsearch-java). Thank you for reporting this!
