elasticsearch(es)获取索引的 mapping 的方法是什么?es 提供了 _mapping 接口。
推荐方式
es 提供了查看指定 index 的字段映射的接口,具体如下:
GET {index}/_mapping
输出如下:
{
"qa": {
"mappings": {
"qa": {
"properties": {
"question": {
"type": "text",
"store": true,
"norms": false,
"index_options": "docs",
"similarity": "BM25",
"copy_to": [
"all_string"
],
"analyzer": "ik_max_word",
"search_analyzer": "ik_smart"
},
"answer": {
"type": "text",
"store": true,
"norms": false,
"index_options": "docs",
"similarity": "BM25",
"copy_to": [
"all_string"
],
"analyzer": "ik_max_word",
"search_analyzer": "ik_smart"
},
"all_string": {
"type": "text",
"store": false,
"similarity": "BM25",
"analyzer": "ik_max_word",
"search_analyzer": "ik_smart"
},
...
如上示例中 index 名是 qa,type 名也是 qa。