# Querying an alias throws off scoring completely?

**URL:** <https://discuss.elastic.co/t/querying-an-alias-throws-off-scoring-completely/351423>\
**Category:** Elasticsearch\
**Created:** [January 19, 2024, 8:28am UTC](https://discuss.elastic.co/t/querying-an-alias-throws-off-scoring-completely/351423 "2024-01-19T08:28:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![pudo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pudo/32/130934_2.png) [@pudo](https://discuss.elastic.co/u/pudo)\
**Post date:** [January 19, 2024, 8:28am UTC](https://discuss.elastic.co/t/querying-an-alias-throws-off-scoring-completely/351423/1 "2024-01-19T08:28:05Z")

</div>

Hey all!

I’m seeing some really weird behaviour around index aliases, maybe I’m doing something conceptually dumb.

We have two indexes of very different size (example: 4mn docs in `entities-a` and 2(!) docs in `entities-b` ), which both point to an alias, `entities`.

Now when I query `entities` for a query that perfectly matches one of the 2 docs in `entities-b`, I get junk results from `entities-a` instead. If I remove `entities-a` from the alias, the query returns the doc from `entities-b` properly.

The sense I’m getting is that the imbalance of the indexes completely throws off relevancy scoring - is that likely? Is there any way to address it?

---

<div class="post-metadata">

**Author:** ![yago82](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yago82/32/97755_2.png) [@yago82](https://discuss.elastic.co/u/yago82)\
**Post date:** [January 19, 2024, 8:55am UTC](https://discuss.elastic.co/t/querying-an-alias-throws-off-scoring-completely/351423/2 "2024-01-19T08:55:49Z")

</div>

Hi,

If you want to prioritize results from `entities-b` over `entities-a` , you can use the `indices_boost` parameter in your search query.

> **[Search API | Elasticsearch Guide \[8.12\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html)**

Regards

---

<div class="post-metadata">

**Author:** ![pudo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pudo/32/130934_2.png) [@pudo](https://discuss.elastic.co/u/pudo)\
**Post date:** [January 19, 2024, 9:03am UTC](https://discuss.elastic.co/t/querying-an-alias-throws-off-scoring-completely/351423/3 "2024-01-19T09:03:54Z")

</div>

Thanks for that hint! While that may be a possible work-around, I would like to understand the problem a bit more before hacking it. The thing is that the match in `entities-b` is a perfect result (unique match on a boosted keyword field), so it should come out on top even if both indexes are queried...

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [January 19, 2024, 9:05am UTC](https://discuss.elastic.co/t/querying-an-alias-throws-off-scoring-completely/351423/4 "2024-01-19T09:05:18Z")

</div>

Have you tried setting [the `search_type` query parameter to `dfs_query_then_fetch`](https://www.elastic.co/guide/en/elasticsearch/reference/8.12/search-search.html#search-search-api-query-params)? Does that make any difference?

---

<div class="post-metadata">

**Author:** ![pudo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pudo/32/130934_2.png) [@pudo](https://discuss.elastic.co/u/pudo)\
**Post date:** [January 19, 2024, 9:08am UTC](https://discuss.elastic.co/t/querying-an-alias-throws-off-scoring-completely/351423/5 "2024-01-19T09:08:43Z")

</div>

That looks to have made a difference!! My sample queries are coming back with the correct doc now. Is this safe to do? Does it point to an underlying issue, or is it just a little price we'll have to pay for this whacky setup?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [January 19, 2024, 9:18am UTC](https://discuss.elastic.co/t/querying-an-alias-throws-off-scoring-completely/351423/6 "2024-01-19T09:18:30Z")

</div>

> [@pudo](#):
>
> Is this safe to do?

Yes. It is a different query mode especially designed for better handling shards with different sizes and distributions of data.

> [@pudo](#):
>
> Does it point to an underlying issue

No, not really. Have a look at the docs and the links therein to distributes term frequences and relevancy scoring.

---

<div class="post-metadata">

**Author:** ![pudo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pudo/32/130934_2.png) [@pudo](https://discuss.elastic.co/u/pudo)\
**Post date:** [January 19, 2024, 9:20am UTC](https://discuss.elastic.co/t/querying-an-alias-throws-off-scoring-completely/351423/7 "2024-01-19T09:20:10Z")

</div>

Thank you very much for your competent help, @Christian_Dahlqvist! Appreciate you taking the time.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 16, 2024, 9:21am UTC](https://discuss.elastic.co/t/querying-an-alias-throws-off-scoring-completely/351423/8 "2024-02-16T09:21:10Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
