I use package elaticsearch in laravel framework:
I has task search name customer when i enter name into input search.
I want search as like in elacticsearch. I want typing "an" will return "Tân", "Ánh","Bằng",..
this is query search api :
public function autocomplete(Request $request)
{
$name = $request->query('q');
$customers = Customer::searchByQuery([
'wildcard' => [
'name' => '*'.$name.'*'
]
]);
}
This is model customer :
class Customer extends Model
{
use ElasticquentTrait;
protected $table = 'customers';
protected $fillable = [ 'name' ];
protected $hidden = [ 'created_at', 'updated_at', 'deleted_at' ];
protected $mappingProperties = array(
'name' => [
'type' => 'text',
"analyzer" => "standard",
],
);
protected $indexSettings = [
'analysis' => [
'analyzer' => [
'my_custom_analyzer' => [
'type' => 'custom',
'char_filter' => [
'html_strip',
'replace',
],
'tokenizer' => 'standard',
'filter' => [
'lowercase',
'asciifolding',
],
],
],
],
];
}
I hope someone can help me. Thanks you very much