Scoring documents according to count on a different document

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.

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