模糊搜索匹配有问题?

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

模糊搜索匹配有问题?

一:设计想法:

1.搜索词分词(根据品牌名称匹配)
搜索词包含品牌词,品牌词包含搜索词,互相只要一项包含
(分词之后做同义词可能会匹配出其他品牌)

2.搜索词(不分词)
搜索词包含品牌词
(增加一个字段品牌词匹配字段,这个字段专门做匹配,比如字段值:小米,xiaomi,XIAOMI)


3.根据搜索词(不分词)包含问题?
搜索小米:搜索不到xiaomi.(业务组必须提供一个字段,来匹配搜索关键词)


二:根据搜索词(分词)后在包含

搜索小米(最大分词):能搜索到xiaomi,由于是最大分词匹配。所以会匹配到,小,米。小米

2018-08-27 10:03:38.775  INFO [lovego-search,8f7294e842046a29,1b91cb8754b13d40,false] 39472 --- [nio-9100-exec-4] c.l.s.service.BrandOptimizationService   : key:Xiaomi/小米 匹配到中文匹配名称:{}
2018-08-27 10:03:38.777  INFO [lovego-search,8f7294e842046a29,1b91cb8754b13d40,false] 39472 --- [nio-9100-exec-4] c.l.s.service.BrandOptimizationService   : key:a 匹配到英文匹配名称:{}
2018-08-27 10:03:38.778  INFO [lovego-search,8f7294e842046a29,1b91cb8754b13d40,false] 39472 --- [nio-9100-exec-4] c.l.s.service.BrandOptimizationService   : key:Bellamys/贝拉米 匹配到中文匹配名称:{}
2018-08-27 10:03:38.778  INFO [lovego-search,8f7294e842046a29,1b91cb8754b13d40,false] 39472 --- [nio-9100-exec-4] c.l.s.service.BrandOptimizationService   : key:Milton/米尔顿 匹配到中文匹配名称:{}
2018-08-27 10:03:38.778  INFO [lovego-search,8f7294e842046a29,1b91cb8754b13d40,false] 39472 --- [nio-9100-exec-4] c.l.s.service.BrandOptimizationService   : key:Ameter/一米 匹配到中文匹配名称:{}
2018-08-27 10:03:38.778  INFO [lovego-search,8f7294e842046a29,1b91cb8754b13d40,false] 39472 --- [nio-9100-exec-4] c.l.s.service.BrandOptimizationService   : key:Yummy Earth/亚米 匹配到中文匹配名称:{}
2018-08-27 10:03:38.778  INFO [lovego-search,8f7294e842046a29,1b91cb8754b13d40,false] 39472 --- [nio-9100-exec-4] c.l.s.service.BrandOptimizationService   : key:Miji/米技 匹配到中文匹配名称:{}
2018-08-27 10:03:38.778  INFO [lovego-search,8f7294e842046a29,1b91cb8754b13d40,false] 39472 --- [nio-9100-exec-4] c.l.s.service.BrandOptimizationService   : key:BAYMAK/巴米克 匹配到中文匹配名称:{}
2018-08-27 10:03:38.779  INFO [lovego-search,8f7294e842046a29,1b91cb8754b13d40,false] 39472 --- [nio-9100-exec-4] c.l.s.service.BrandOptimizationService   : key:多米诺 匹配到中文匹配名称:{}
2018-08-27 10:03:38.779  INFO [lovego-search,8f7294e842046a29,1b91cb8754b13d40,false] 39472 --- [nio-9100-exec-4] c.l.s.service.BrandOptimizationService   : key:米小胖 匹配到中文匹配名称:{}
2018-08-27 10:03:38.779  INFO [lovego-search,8f7294e842046a29,1b91cb8754b13d40,false] 39472 --- [nio-9100-exec-4] c.l.s.service.BrandOptimizationService   : key:Xiaomi/小米 匹配到中文匹配名称:{}
2018-08-27 10:03:38.779  INFO [lovego-search,8f7294e842046a29,1b91cb8754b13d40,false] 39472 --- [nio-9100-exec-4] c.l.s.service.BrandOptimizationService   : key:米蔻 匹配到中文匹配名称:{}
2018-08-27 10:03:38.779  INFO [lovego-search,8f7294e842046a29,1b91cb8754b13d40,false] 39472 --- [nio-9100-exec-4] c.l.s.service.BrandOptimizationService   : key:RICE DAY/米时代 匹配到中文匹配名称:{}
2018-08-27 10:03:38.779  INFO [lovego-search,8f7294e842046a29,1b91cb8754b13d40,false] 39472 --- [nio-9100-exec-4] c.l.s.service.BrandOptimizationService   : key:米妮哈鲁 匹配到中文匹配名称:{}
2018-08-27 10:03:38.779  INFO [lovego-search,8f7294e842046a29,1b91cb8754b13d40,false] 39472 --- [nio-9100-exec-4] c.l.s.service.BrandOptimizationService   : key:Miji 米技 匹配到中文匹配名称:{}
2018-08-27 10:03:38.780  INFO [lovego-search,8f7294e842046a29,1b91cb8754b13d40,false] 39472 --- [nio-9100-exec-4] c.l.s.service.BrandOptimizationService   : key:五米常香 匹配到中文匹配名称:{}
2018-08-27 10:03:38.780  INFO [lovego-search,8f7294e842046a29,1b91cb8754b13d40,false] 39472 --- [nio-9100-exec-4] c.l.s.service.BrandOptimizationService   : key:朵唯尔米 匹配到中文匹配名称:{}
2018-08-27 10:03:38.780  INFO [lovego-search,8f7294e842046a29,1b91cb8754b13d40,false] 39472 --- [nio-9100-exec-4] c.l.s.service.BrandOptimizationService   : key:拉米奇 匹配到中文匹配名称:{}
2018-08-27 10:03:38.780  INFO [lovego-search,8f7294e842046a29,1b91cb8754b13d40,false] 39472 --- [nio-9100-exec-4] c.l.s.service.BrandOptimizationService   : key:AC米兰 匹配到中文匹配名称:{}
2018-08-27 10:03:38.780  INFO [lovego-search,8f7294e842046a29,1b91cb8754b13d40,false] 39472 --- [nio-9100-exec-4] c.l.s.service.BrandOptimizationService   : key:MICHELIN/米其林 匹配到中文匹配名称:{}
2018-08-27 10:03:38.780  INFO [lovego-search,8f7294e842046a29,1b91cb8754b13d40,false] 39472 --- [nio-9100-exec-4] c.l.s.service.BrandOptimizationService   : key:MOMAX/摩米士 匹配到中文匹配名称:{}
2018-08-27 10:03:38.782  INFO [lovego-search,8f7294e842046a29,1b91cb8754b13d40,false] 39472 --- [nio-9100-exec-4] c.l.s.service.BrandOptimizationService   : key:the little sugar milk baby/一米半糖 匹配到中文匹配名称:{}
2018-08-27 10:03:38.782  INFO [lovego-search,8f7294e842046a29,1b91cb8754b13d40,false] 39472 --- [nio-9100-exec-4] c.l.s.service.BrandOptimizationService   : key:BeddyMia/贝迪米娅 匹配到中文匹配名称:{}
2018-08-27 10:03:38.783  INFO [lovego-search,8f7294e842046a29,1b91cb8754b13d40,false] 39472 --- [nio-9100-exec-4] c.l.s.service.BrandOptimizationService   : key:凡米 匹配到中文匹配名称:{}
2018-08-27 10:03:38.787  INFO [lovego-search,8f7294e842046a29,1b91cb8754b13d40,false] 39472 --- [nio-9100-exec-4] c.l.s.service.BrandOptimizationService   : key:机械师 匹配到中文匹配名称:{}
2018-08-27 10:03:38.793  INFO [lovego-search,8f7294e842046a29,1b91cb8754b13d40,false] 39472 --- [nio-9100-exec-4] c.l.s.service.BrandOptimizationService   : key:Xiaomi/小米 匹配到中文匹配名称:{}
2018-08-27 10:03:38.795  INFO [lovego-search,8f7294e842046a29,1b91cb8754b13d40,false] 39472 --- [nio-9100-exec-4] c.l.s.service.BrandOptimizationService   : key:a 匹配到英文匹配名称:{}
2018-08-27 10:03:38.798  INFO [lovego-search,8f7294e842046a29,1b91cb8754b13d40,false] 39472 --- [nio-9100-exec-4] c.l.s.service.BrandOptimizationService   : key:Xiaomi/小米 匹配到中文匹配名称:{}

搜索小米(最小分词):能搜索到xiaomi,由于是最大分词匹配。所以会匹配到, 小米。由于同义词会匹配a

2018-08-27 10:11:56.602  INFO [lovego-search,61de2117481d7540,cb57d04699738974,false] 36132 --- [nio-9100-exec-1] c.l.s.service.BrandOptimizationService   : key:xiaomi 匹配到中文匹配名称:Xiaomi/小米
2018-08-27 10:11:56.604  INFO [lovego-search,61de2117481d7540,cb57d04699738974,false] 36132 --- [nio-9100-exec-1] c.l.s.service.BrandOptimizationService   : key:xiaomi 匹配到英文匹配名称:a
2018-08-27 10:11:56.613  INFO [lovego-search,61de2117481d7540,cb57d04699738974,false] 36132 --- [nio-9100-exec-1] c.l.s.service.BrandOptimizationService   : key:Xiaomi/小米 匹配到中文匹配名称:Xiaomi/小米
2018-08-27 10:11:56.616  INFO [lovego-search,61de2117481d7540,cb57d04699738974,false] 36132 --- [nio-9100-exec-1] c.l.s.service.BrandOptimizationService   : key:Xiaomi/小米 匹配到英文匹配名称:a
2018-08-27 10:11:56.620  INFO [lovego-search,61de2117481d7540,cb57d04699738974,false] 36132 --- [nio-9100-exec-1] c.l.s.service.BrandOptimizationService   : key:小米 匹配到中文匹配名称:Xiaomi/小米
2018-08-27 10:11:56.623  INFO [lovego-search,61de2117481d7540,cb57d04699738974,false] 36132 --- [nio-9100-exec-1] c.l.s.service.BrandOptimizationService   : 匹配  brandIds: [2782, 1359]  key : 小米手机


总结:
如果用搜索词分词后匹配,词典里面必须配置品牌名称。而且,必须用ik_smart。但是匹配到同义词之后,还是会出现匹配到a这种情况


最终方案:
根据搜索词ik_smart分词(词典里面必须包含品牌词),然后根据品牌名称是否包含搜索词项。包含则匹配品牌

转载于:https://my.oschina.net/xiaominmin/blog/1935138

你可能感兴趣的:(模糊搜索匹配有问题?)