0
我正在使用彈性搜索2.2.0,並且我是新的。我想使用兩個過濾器搜索結果,但它顯示我致命錯誤:查詢不支持多個字段。多項術語過濾器不適用於彈性搜索
兩個濾波器:
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'];
有另一種方式去了解什麼,我試圖做的,還是我在正確的軌道上?
也請提供您的索引/類型的結構 – Dekel