# Ranking across indices using dfs\_query\_then\_fetch

**URL:** <https://discuss.elastic.co/t/ranking-across-indices-using-dfs-query-then-fetch/189865>\
**Category:** Elasticsearch\
**Created:** [July 10, 2019, 8:05pm UTC](https://discuss.elastic.co/t/ranking-across-indices-using-dfs-query-then-fetch/189865 "2019-07-10T20:05:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mop\_handler](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mop_handler/32/46158_2.png) [@mop\_handler](https://discuss.elastic.co/u/mop_handler)\
**Post date:** [July 10, 2019, 8:05pm UTC](https://discuss.elastic.co/t/ranking-across-indices-using-dfs-query-then-fetch/189865/1 "2019-07-10T20:05:54Z")

</div>

We have a single search across multiple indices using `simple_query_string`. The problem is that the ranking is pretty awful, and the top few results are always from a particular index. I've been told this is because tf/idf is calculated for each individual index and then ranking is determined between indices, but this makes indices with lower idf to show up higher.

Looking at the documentation, [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-search-type.html#dfs-query-then-fetch](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-search-type.html#dfs-query-then-fetch) computes cross-shard idf and uses that for ranking. The docs for that say to not use it for production. I assume this also meant it computes idf across index as well.

These indices have a set of 3-5 fields that are common (like inheritance), and a bunch of other specific fields.

One option is to just put everything in one index and leave fields blank where they don't apply.

The other option is to use dfs\_query\_then\_fetch.

Which is recommended, and which is the usual solution people use in cases like this?

---

<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:** [August 7, 2019, 8:05pm UTC](https://discuss.elastic.co/t/ranking-across-indices-using-dfs-query-then-fetch/189865/2 "2019-08-07T20:05:55Z")

</div>

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