Array attribute relations

took #3918 and added tests for elasticsearch.
Tests are only failing because of #4379.

@qiangxue what do you think? Imo this is good to merge.

fixes #1249, closes #3918, fixes #4379