2016-12-09 36 views
0

我有一個值的數組,我想要搜索並顯示其內容。排序數組並以數組當前格式顯示結果的最佳方法是什麼?如何排序elasticsearch中的多重數組值搜索

$myarray=array('84790','19162002','74739','86439','88820','19560020','19634461','19624154','19624091','19577228'); 

{ 
    "query":{ 
     "filtered":{ 
     "filter":{ 
      "bool":{ 
       "should":[ 
        { 
        "term":{ 
         "podcast_id":"84790" 
        } 
        }, 
        { 
        "term":{ 
         "podcast_id":"19162002" 
        } 
        }, 
        { 
        "term":{ 
         "podcast_id":"74739" 
        } 
        }, 
        { 
        "term":{ 
         "podcast_id":"86439" 
        } 
        }, 
        { 
        "term":{ 
         "podcast_id":"88820" 
        } 
        }, 
        { 
        "term":{ 
         "podcast_id":"19560020" 
        } 
        }, 
        { 
        "term":{ 
         "podcast_id":"19634461" 
        } 
        }, 
        { 
        "term":{ 
         "podcast_id":"19624154" 
        } 
        }, 
        { 
        "term":{ 
         "podcast_id":"19624091" 
        } 
        }, 
        { 
        "term":{ 
         "podcast_id":"19577228" 
        } 
        } 
       ] 
      } 
     } 
     } 
    } 
} 

我使用PHP中,捲曲和post方法我的數組值。

感謝

回答

0

可以使用Terms filter insted的。

財產以後這樣的:

{ 
"query": { 
    "filtered": { 

     "filter": { 
      "terms": { 
       "podcast_id": [ 
       "84790", 
       "19162002", 
       ..... 
       ] 
      } 
     } 
    } 
    } 
}