elasticsearch6.x 使用聚合API,聚合属性字段出现分词情况解析

你猜 阅读:236 2021-03-31 13:47:36 评论:0

针对索引库中类型的映射mapping 采用keyword 关键字,即表示:不分词。

实列:创建Boob 索引库:

创建Book 索引库中的archInfo类型 ,及其类型映射:

Body 详细参数:

{ 
    "archInfo": { 
        "properties": { 
            "sid":{ 
     "type": "text", 
     "store": true 
}, 
"unitprojsid":{ 
    "type": "text", 
    "store": true 
}, 
"individualprojsid": { 
    "type": "text", 
    "store": true 
}, 
"engprojsid": { 
    "type": "text", 
    "store": true 
}, 
"assortnum": { 
    "type": "text", 
    "store": true, 
    "index":true,  
    "analyzer":"ik_max_word" 
}, 
"organizationcode": { 
    "type": "text", 
    "store": true, 
    "index":true,  
    "analyzer":"ik_max_word" 
}, 
"assortnumname": { 
    "type": "keyword" 
    
}, 
"organizationcodename": { 
    "type": "keyword" 
}, 
"archid": { 
    "type": "text", 
    "store": true 
}, 
"unitprojarchno": { 
    "type": "text", 
    "store": false, 
    "index":true,  
    "analyzer":"ik_max_word" 
}, 
"regno": { 
    "type": "text", 
    "store": false, 
    "index":true,  
    "analyzer":"ik_max_word" 
}, 
"archtitle": { 
     "type": "text", 
    "store": false, 
    "index":true,  
    "analyzer":"ik_max_word" 
}, 
"makeorgname": { 
     "type": "text", 
    "store": false, 
    "index":true,  
    "analyzer":"ik_max_word" 
}, 
"archtypecode": { 
    "type": "text", 
    "store": false, 
    "index":true,  
    "analyzer":"ik_max_word" 
}, 
"speccode": { 
    "type": "text", 
    "store": false, 
    "index":true,  
    "analyzer":"ik_max_word" 
}, 
"startdate": { 
	"type": "date" 
}, 
"enddate": { 
	"type": "date" 
}, 
"securitylevelcode": { 
	"type": "text" 
}, 
"storagetypecode": { 
	"type": "text" 
}, 
"archtypename": { 
	"type": "text" 
}, 
"archtype": { 
	"type": "text" 
}, 
"archcategorycode": { 
	"type": "text", 
               "store": true 
}, 
"archivingdate": { 
	"type": "date" 
}, 
"archivingdateyear": { 
	"type": "text", 
    "fielddata":true 
}, 
"unitprojtype": { 
    "type": "text", 
    "fielddata":true 
}, 
"unitprojzone": { 
    "type": "text", 
    "fielddata":true 
} 
 
        }  
    }  
}

 重点注意:assortnumname 和organizationcodename 的属性值设置为keyword.

使用上述两个属性进行聚合统计:

声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

发表评论
搜索
排行榜
KIKK导航

KIKK导航

关注我们