我想用elasticsearch搜索并用php显示结果。我想像 mysql 中那样进行部分匹配,例如:
select * from table_name where title like '%abc%'
但是我的代码不起作用:
$params = [
'index' => 'my_index',
'type' => 'my_type',
'body' => [
'query' => [
'match' => [
'title' => '.*abc.*'
]
]
]
];
最佳答案
我使用“match”而不是“regex”
$params = [
'index' => 'my_index',
'type' => 'my_type',
'body' => [
'query' => [
'regexp' => [
'title' => '.*abc.*'
]
]
]
];
关于PHP elasticsearch 部分匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46592860/