Elasticsearch: how to get distinct value from two indeices?


i have index1 and index2 indexs , index2 have two types :user,tweet ,
index1 have a index1_loc field and index2 have indice2_loc , index1 and index2 document will be looks like as follows,

index1 documents:

{"index1_loc": "10.0.0.1"},
{"index1_loc": "10.0.0.1"},
{"index1_loc": "10.1.1.1"},
{"index1_loc": "10.1.1.1"},
{"index1_loc": "10.0.0.2"}

index2 documents:

{"index2_loc": "10.0.0.1"},
{"index2_loc": "10.0.2.2"},
{"index2_loc": "10.1.1.1"},
{"index2_loc": "10.0.1.1"},
{"index2_loc": "10.0.0.2"}

i can use aggregation but it only returned from one index with the query

{
 "size": 0,
 "aggs" : {
"langs" : {
        "terms" : { 
           "field" : "index1_loc" ,
            "size": 0
                  }
          }
     }
 }'

in php,

$url = '<myurl>:<myport>/index1-*/_search?pretty';
$data = array(
		 "size" => 0,
		  "aggs" => array (
		       "Loc" => array (
		           "terms" => array ( 
		                 "field" => "index1_loc" ,
		                 "size" => 0
					 	            )
				              )
				           )
			   )

i want to get the results like the sql ,

select distinct t.loc as loc from (
   select index1_loc  as loc from index1
   union 
   select index2_loc as loc from index2
) t

expected results document will be get as follows,

{"loc": "10.0.0.1"},
{"loc": "10.1.1.1"},
{"loc": "10.0.2.2"},
{"loc": "10.0.0.2"},
{"loc": "10.0.1.1"},




$url = '<myurl>:<myport>/index1-*,index2-*/_search?pretty';
$data = //howo to get distinct value from two indeices with two fields ???????

Thank for your help!