# Rescoring documents based on Author occurrence

**URL:** https://discuss.elastic.co/t/rescoring-documents-based-on-author-occurrence/254942
**Category:** Elasticsearch
**Created:** [November 10, 2020, 3:59pm UTC](https://discuss.elastic.co/t/rescoring-documents-based-on-author-occurrence/254942 "2020-11-10T15:59:59Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Charles\_Lariviere](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/charles_lariviere/32/67753_2.png) [@Charles\_Lariviere](https://discuss.elastic.co/u/Charles_Lariviere)
#### Post date: [November 10, 2020, 3:59pm UTC](https://discuss.elastic.co/t/rescoring-documents-based-on-author-occurrence/254942/1 "2020-11-10T15:59:59Z")

</div>

Hey!

We have an index with documents that look like so:

```auto
{
    "id": "1",
    "author_id": "8",
    "popularity": 2.5,
    "tags": ["illustration", "book", "image"]
}

```

We search this index for documents matching given `tags` and sort them using a `script_score` (i.e. using `popularity` and other variables). In some cases though, almost all top ranking documents are from the same `author`which is undesirable.

Therefore, we're looking for a way to decrease a document's score given it's author-occurrence-count, such that given the following results:

```auto
[
    {"id": "1", "author_id": 8, ...}, # author-occurrence-count: 1
    {"id": "5", "author_id": 8, ...}, # author-occurrence-count: 2
    {"id": "7": "author_id": 7, ...}, # author-occurrence-count: 1,
    {"id": "3", "author_id": 8, ...}, # author-occurrence-count: 3
    ...
]

```

We could re-score the result set to include the `author-occurrence-count` in the `script_score` and apply a monotonically decreasing function. The real unknown is how can we get the Elasticsearch query to return this type of variable such that it is available in a rescoring query -- and whether this is even possible!

Thanks!  
Charles

---

<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: [December 8, 2020, 4:00pm UTC](https://discuss.elastic.co/t/rescoring-documents-based-on-author-occurrence/254942/2 "2020-12-08T16:00:01Z")

</div>

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