ElasticSearch(7.2.2)-映射的介绍和使用

2019-10-30 20:12:49 浏览数 (1)

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

本文链接:https://blog.csdn.net/weixin_42528266/article/details/102798169

简介:手把手教你怎么操作mapping

新增
  • 请求
代码语言:javascript复制
curl -X PUT "localhost:9200/nba/_mapping" -H 'Content-Type:
application/json' -d'
{
	"properties": {
		"name": {
			"type": "text"
		},
		"team_name": {
			"type": "text"
		},
		"position": {
			"type": "keyword"
		},
		"play_year": {
			"type": "keyword"
		},
		"jerse_no": {
			"type": "keyword"
		}
	}
}
  • 响应
代码语言:javascript复制
{
 "acknowledged": true
}
获取
  • 请求
代码语言:javascript复制
curl -X GET "localhost:9200/xdclass/_mapping"
  • 响应
代码语言:javascript复制
{
	"nba": {
		"mappings": {
			"properties": {
				"jerse_no": {
					"type": "keyword"
				},
				"name": {
					"type": "text"
				},
				"play_year": {
					"type": "keyword"
				},
				"position": {
					"type": "keyword"
				},
				"team_name": {
					"type": "text"
				}
			}
		}
	}
}
批量获取
  • 请求
代码语言:javascript复制
curl -X GET "localhost:9200/nba,cba/mapping"
  • 响应
代码语言:javascript复制
{
	"nba": {
		"mappings": {
			"properties": {
				"jerse_no": {
					"type": "keyword"
				},
				"name": {
					"type": "text"
				},
				"play_year": {
					"type": "keyword"
				},
				"position": {
					"type": "keyword"
				},
				"team_name": {
					"type": "text"
				}
			}
		}
	},
	"cba": {
		"mappings": {}
	}
}
获取所有
  • 请求(一)
代码语言:javascript复制
curl -X GET "localhost:9200/_mapping"
  • 响应(一)
代码语言:javascript复制
{
	"nba": {
		"mappings": {
			"properties": {
				"jerse_no": {
					"type": "keyword"
				},
				"name": {
					"type": "text"
				},
				"play_year": {
					"type": "keyword"
				},
				"position": {
					"type": "keyword"
				},
				"team_name": {
					"type": "text"
				}
			}
		}
	},
	"cba": {
		"mappings": {}
	}
}
  • 请求(二)
代码语言:javascript复制
curl -X GET "localhost:9200/_all/_mapping"
  • 响应(二)
代码语言:javascript复制
{
	"nba": {
		"mappings": {
			"properties": {
				"jerse_no": {
					"type": "keyword"
				},
				"name": {
					"type": "text"
				},
				"play_year": {
					"type": "keyword"
				},
				"position": {
					"type": "keyword"
				},
				"team_name": {
					"type": "text"
				}
			}
		}
	},
	"cba": {
		"mappings": {}
	}
}
修改
  • 请求
代码语言:javascript复制
curl -X PUT "localhost:9200/nba/_mapping" -H 'Content-Type:
application/json' -d'
{
	"properties": {
		"name": {
			"type": "text"
		},
		"team_name": {
			"type": "text"
		},
		"position": {
			"type": "keyword"
		},
		"play_year": {
			"type": "keyword"
		},
		"jerse_no": {
			"type": "keyword"
		},
		"country": {
			"type": "keyword"
		}
	}
}
  • 响应
代码语言:javascript复制
{
 "acknowledged": true
}

0 人点赞