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

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

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

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

新增
  • 请求
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"
		}
	}
}
  • 响应
{
 "acknowledged": true
}
获取
  • 请求
curl -X GET "localhost:9200/xdclass/_mapping"
  • 响应
{
	"nba": {
		"mappings": {
			"properties": {
				"jerse_no": {
					"type": "keyword"
				},
				"name": {
					"type": "text"
				},
				"play_year": {
					"type": "keyword"
				},
				"position": {
					"type": "keyword"
				},
				"team_name": {
					"type": "text"
				}
			}
		}
	}
}
批量获取
  • 请求
curl -X GET "localhost:9200/nba,cba/mapping"
  • 响应
{
	"nba": {
		"mappings": {
			"properties": {
				"jerse_no": {
					"type": "keyword"
				},
				"name": {
					"type": "text"
				},
				"play_year": {
					"type": "keyword"
				},
				"position": {
					"type": "keyword"
				},
				"team_name": {
					"type": "text"
				}
			}
		}
	},
	"cba": {
		"mappings": {}
	}
}
获取所有
  • 请求(一)
curl -X GET "localhost:9200/_mapping"
  • 响应(一)
{
	"nba": {
		"mappings": {
			"properties": {
				"jerse_no": {
					"type": "keyword"
				},
				"name": {
					"type": "text"
				},
				"play_year": {
					"type": "keyword"
				},
				"position": {
					"type": "keyword"
				},
				"team_name": {
					"type": "text"
				}
			}
		}
	},
	"cba": {
		"mappings": {}
	}
}
  • 请求(二)
curl -X GET "localhost:9200/_all/_mapping"
  • 响应(二)
{
	"nba": {
		"mappings": {
			"properties": {
				"jerse_no": {
					"type": "keyword"
				},
				"name": {
					"type": "text"
				},
				"play_year": {
					"type": "keyword"
				},
				"position": {
					"type": "keyword"
				},
				"team_name": {
					"type": "text"
				}
			}
		}
	},
	"cba": {
		"mappings": {}
	}
}
修改
  • 请求
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"
		}
	}
}
  • 响应
{
 "acknowledged": true
}

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区

领取腾讯云代金券

年度创作总结 领取年终奖励