现在有一个搜索sql:
select * from xxx where title like '%zzz%' or details like '%zzz%'
即搜索出title和details中包含zzz的条目。
例如结果为
id title details
1 xxx xxx zzz yyy
2 zzzy xxxxxxxxx
3 ffff zzzyy
现在有个需求,就是要加入个排序。也就是按照title搜索到的结果排在前面(优先),按照details搜索到的结果排在后面,即
id title details
2 zzzy xxxxxxxxx
1 xxx xxx zzz yyy
3 ffff zzzyy
这个如何实现?
使用es,加大title搜索权重