# Ranking short vs. long documents vs nested docs

**URL:** <https://discuss.elastic.co/t/ranking-short-vs-long-documents-vs-nested-docs/134318>\
**Category:** Elasticsearch\
**Created:** [June 3, 2018, 4:01pm UTC](https://discuss.elastic.co/t/ranking-short-vs-long-documents-vs-nested-docs/134318 "2018-06-03T16:01:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![randel\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/randel_2/32/31785_2.png) [@randel\_2](https://discuss.elastic.co/u/randel_2)\
**Post date:** [June 3, 2018, 4:01pm UTC](https://discuss.elastic.co/t/ranking-short-vs-long-documents-vs-nested-docs/134318/1 "2018-06-03T16:01:34Z")

</div>

A search with standard settings ranks hits in documents with fewer words higher than longer texts. The word count seems to also take all nested documents into consideration.

Lets say I have:

```
PUT /books/_doc/1
{
  "editions": [
    {
      "title": "apes"
    }
  ]
}

PUT /books/_doc/2
{
  "editions": [
    {
      "title": "a group of apes"
    }
  ]
}

PUT /books/_doc/3
{
  "editions": [
    {
      "title": "chimpansee kingdom"
    },
    {
      "title": "apes"
    }
  ]
}

```

Search:

```
POST /books/_search
{
  "query": {
    "bool": {
      "should": [
        {
          "nested": {
            "path": "editions",
            "query": {
              "match": {
                "editions.title": {
                  "query": "apes"
                }
              }
            }
          }
        }
      ]
    }
  }
}

```

Right now book id 1 ranks highest followed by 2 and last comes 3.  
Can I restrict that effect to the length of the nested document with the hit instead of taking all nested documents into account so that book id 1 and 3 rank hightest (equally) followed by 2?

---

<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:** [July 1, 2018, 4:01pm UTC](https://discuss.elastic.co/t/ranking-short-vs-long-documents-vs-nested-docs/134318/2 "2018-07-01T16:01:35Z")

</div>

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