我在 elasticsearch indexproducts_idx1
和 type中添加了 15k 条记录product
。
在记录产品名称apple iphone 6
时,当我搜索iphone6
它时,它会返回空数据。
这是我在 php elasticsearch 中的代码
<?php
use Elasticsearch\ClientBuilder;
require 'vendor/autoload.php';
$client = ClientBuilder::create()->build();
$values =['name','name.prefix','name.suffix','sku'];
$params =
[
'client'=>['verify'=>1,'connect_timeout'=>5],
'from'=> 0,
'size'=>25,
'body' =>[
'query' => [
'bool'=>
[
'should'=> [[
'multi_match'=> ['query'=>'iphone6','type'=>'cross_fields','fields'=>$values,'operator'=>'OR']
],
['match'=>['all'=>['query'=>'iphone6','operator'=>'OR','fuzziness'=>'AUTO'] ]]
]
]
],
'sort'=>['_score'=>['order'=>'desc']],
],
'index'=>'products_idx1'
];
$response = $client->search($params);
echo "<pre>";print_r($response);