文本排序与词干提取技术详解
不区分大小写的排序
假设我们有三个用户文档,其 name 字段分别包含 Boffey 、 BROWN 和 bailey 。为了对这些文档进行排序,我们可以使用未分析的字段。以下是具体操作步骤:
1. 创建索引映射 :
PUT /my_index
{
"mappings": {
"user": {
"properties": {
"name": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
}
在这个映射中,分析过的 name 字段用于搜索,未分析的 name.raw 字段用于排序。
2. 索引文档并排序 :
PUT /my_index/user/1
{ "name": "Boffey" }
PUT /my_index/user/2
{ "nam
超级会员免费看
订阅专栏 解锁全文
1万+

被折叠的 条评论
为什么被折叠?



