2016-07-24 8 views
0

私は弾性検索2.2.0を使用しています。私は2つのフィルタを使用して結果を検索したいが、それは致命的なエラーを示しています:クエリは複数のフィールドをサポートしていません。複数の用語フィルタが弾性検索で機能していません

つのフィルタは、次のとおりです。

plocation: china 
pcategoryid: 0,20,21 

ここに私のコードです:

$search = 'Doors'; 
$limit = 6; 
$params = [ 
    'index' => 'product', 
    'body' => [ 
     'query' => [ 
      "bool" => [ 
       "should" => [ 
        'multi_match' => [ 
         "fields" => [ 
          "pname", 
          "pmodel", 
          "pcategoryname", 
          "pmetakeyword" 
         ], 
         "query" => $search, 
         "type" => "phrase", 
         "boost" => 10 
        ], 
        'multi_match' => [ 
         "fields" => [ 
          "pname", 
          "pmodel", 
          "pcategoryname", 
          "pmetakeyword" 
         ], 
         "query" => $search, 
         "type" => "most_fields", 
         "fuzziness" => "1", 
         "boost" => 0 
        ] 
       ] 
      ], 
     ], 

     "filter" => [ 
      "bool" => [ 
       "must" => [ 
        "term" => [ 
         "ptypeid" => 1 
        ] 
       ], 
       "should" => [ 
        "term" => [ 
         "psearchstatus" => 1 
        ] 
       ], 
       "filter" => [ 
        "terms" => [ 
         "plocation" => ['china'], "pcategoryid" => [0,20,21] 
        ] 
       ] 
      ], 
     ], 
     "from" => ($page - 1) * $limit, 
     "size" => $limit 
    ], 
]; 
$client = Elasticsearch\ClientBuilder::create()->build(); 
$response = $client->search($params); 
$results = $response['hits']['hits']; 

は私がしようとしてる、または私は正しい軌道に乗っています何について行くにあり、他の方法は何ですか?

+0

が – Dekel

答えて

-2

問題は、適用しようとしているterms filterです。上記のtermフィルタのように、1つのフィールドだけを受け入れますが、値の配列を持ちます。

"terms" => [ 
    "plocation" => ['china'], "pcategoryid" => [0,20,21] 
] 

が、これはドライブバイdownvotedた理由

"terms" => [ 
    "plocation" => ['china'] 
], 
"terms" => [ 
    "pcategoryid" => [0,20,21] 
] 
+0

ないアイデアもあなたのインデックス/タイプの構造を提供しないてくださいする必要がありますが、これは問題です。 – pickypg

関連する問題