ElasticSearch 索引控制与数据处理深度解析
1. 索引映射与编解码器配置
在 ElasticSearch 中,索引映射定义了文档的结构和字段类型。假设我们有一个 posts 索引,其映射存储在 posts.json 文件中,内容如下:
{
"mappings" : {
"post" : {
"properties" : {
"id" : { "type" : "long", "store" : "yes", "precision_step" : "0" },
"name" : { "type" : "string", "store" : "yes", "index" : "analyzed" },
"contents" : { "type" : "string", "store" : "no", "index" : "analyzed" }
}
}
}
}
编解码器是按字段定义的。若要配置字段使用编解码器,需添加 postings_format 属性并指定所需编解码器的值,例如 pulsing 。引入该编解码器后,映射文件(存储在 posts_codec.json 中)如下:
{
"mappings" : {
"post" : {
"propertie
超级会员免费看
订阅专栏 解锁全文
4492

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



