Compare field value of different index

Hi ,
Can you please guide me to the following problem,
I have two different index and i want to compare two fields value and get result which exist in different index

for example :-
Index 1: message
fields :- 1. message id
2. message
3. userid

Index 2: user
fields:- 1. userid
2. user name

Need query : Give messageid, message, username
where message.userid = user.userid

I have tried script filter (query given below) but it is not working for different document

curl -XGET 'http://localhost:9200/test1_index,test2_index/_search' -d '
{ "query":
{ "filtered" : { "query" :
{ "match_all" : { } },
"filter" :
{ "script" :
{"script" : "doc["msgid"].value == doc["userid"].value" }
}
} }}'