# Scoring documents according to count on a different document

**URL:** <https://discuss.elastic.co/t/scoring-documents-according-to-count-on-a-different-document/24625>\
**Category:** Elasticsearch\
**Created:** [June 30, 2015, 1:21pm UTC](https://discuss.elastic.co/t/scoring-documents-according-to-count-on-a-different-document/24625 "2015-06-30T13:21:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![edmondo1984](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/edmondo1984/32/3517_2.png) [@edmondo1984](https://discuss.elastic.co/u/edmondo1984)\
**Post date:** [June 30, 2015, 1:21pm UTC](https://discuss.elastic.co/t/scoring-documents-according-to-count-on-a-different-document/24625/1 "2015-06-30T13:21:50Z")

</div>

Hello,

Is it possible to score a document using a count query on another document of a different type within the same index?

Whenever someone loads through my application document a, I add a document b that says “document a with id 1234” has been loaded. I would like to join this information to perform scoring when someone searches on A.

At the moment the only solution I have found is to call a COUNT on B every time someone performs a search on A. I am working with small numbers, but my problem is that if my query on A returns 20 elements, I need to perform 20 counts to retrieve how many B elements matching A.ID exists.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [July 2, 2015, 4:22am UTC](https://discuss.elastic.co/t/scoring-documents-according-to-count-on-a-different-document/24625/2 "2015-07-02T04:22:40Z")

</div>

I do think you have (m)any options here and your approach would be the best one.

---

<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 6, 2017, 12:04am UTC](https://discuss.elastic.co/t/scoring-documents-according-to-count-on-a-different-document/24625/3 "2017-07-06T00:04:01Z")

</div>


