analysis-ik icon indicating copy to clipboard operation
analysis-ik copied to clipboard

IK搜索 “苹果 耳机“ 会连包含“机“字的都搜索出来了

Open lihuaqin-1996 opened this issue 4 years ago • 3 comments

GET _analyze?pretty { "analyzer":"ik_smart", "text":"苹果 耳机" } 分词结果 { "tokens" : [ { "token" : "苹果", "start_offset" : 0, "end_offset" : 2, "type" : "CN_WORD", "position" : 0 }, { "token" : "耳机", "start_offset" : 3, "end_offset" : 5, "type" : "CN_WORD", "position" : 1 } ] }

现在分了两个词,但是搜索的时候却发现,搜索结果里面有包含单个字也搜索出来了。 我要如何设置才能只搜索到分词的内容呢?谢谢

lihuaqin-1996 avatar Jan 19 '21 06:01 lihuaqin-1996

你搜索是怎么写的?mappings里面有没有配置search_analyzer?

NingerJohn avatar Jan 19 '21 07:01 NingerJohn

你搜索是怎么写的?mappings里面有没有配置search_analyzer?

我是用springboot 注解生成的 @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")

lihuaqin-1996 avatar Jan 19 '21 07:01 lihuaqin-1996

看mapping指定是否成功

3269199948 avatar Jul 13 '21 02:07 3269199948