For most recent minecraft.
/damage @e[type=minecraft:wolf,distance=..20,sort=nearest,limit=1] 1 minecraft:arrow by @e[type=minecraft:villager,distance=..20,limit=1]
Note: replace villager and wolf with something else to change the attacker and attackee respectively.