building_id字段做个如下配置:
'building_id' => array( 'type' => 'string', 'analyzer'=>'ik_smart' )
然后我往里面插入了五个文档: '激光器大旅',
'808 激光器2',
'808 大旅',
'808大旅',
'很大旅行再来一个'
搜索的条件如下:'query' => [ 'match' => [ '
building_id' => '808 大旅' ] ]
结果如下hits部分:[hits] => Array
(
[0] => Array
(
[_index] => smart
[_type] => smart
[_id] => 1
[_score] => 1.5996621
[_source] => Array
(
[building_id] => 激光器大旅
)
)
[1] => Array
(
[_index] => smart
[_type] => smart
[_id] => 2
[_score] => 1.0151966
[_source] => Array
(
[building_id] => 808 激光器2
)
)
[2] => Array
(
[_index] => smart
[_type] => smart
[_id] => 3
[_score] => 0.7594807
[_source] => Array
(
[building_id] => 808 大旅
)
)
[3] => Array
(
[_index] => smart
[_type] => smart
[_id] => 4
[_score] => 0.7133084
[_source] => Array
(
[building_id] => 808大旅
)
)
)
为何后面两个不是在第一位不是得分最高呢?后面两个有我搜索的所有关键字啊
1 个回复
rockybean - Elastic Certified Engineer, ElasticStack Fans,公众号:ElasticTalk
赞同来自: