Boost/sort results based on array intersection

I'm interested in including a list of numeric ids in my index, like:

some_ids: [1234, 2345, 3456,...]

Then I'd like to pass another array of ids in with my search such that the more ids that the search array has in common with the indexed array, the more relevant the result is.

Ideally an array of ids that is the intersection of the search array and the indexed array could be returned with the result.

The number of ids in each array will typically be under 100, but could grow to thousands on both the index side and they query side.

Anyone know if this is feasible and what a good approach might be?

Thanks in advance!