curl方式创建elasticsearch的mapping

curl方式创建elasticsearch的mapping

curl -XPUT 'http://192.168.1.105:9200/bank/item2/_mapping' -d '
{
"item2": {
"properties": {
"title": {
"type": "string",
"boost": 2.0,
"index": "analyzed",
"store": "yes",
"term_vector" : "with_positions_offsets"
},
"description": {
"type": "string",
"boost": 1.0,
"index": "analyzed",
"store": "yes",
"term_vector" : "with_positions_offsets"
},
"link": {
"type": "geo_point"
},
"ip": {
"store": true,
"type": "ip"
}
}
}
}'

转载于:https://www.cnblogs.com/mayidudu/p/5776658.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您可以使用 curl 命令来设置 Elasticsearch 中的 mapping,以下是设置 mapping 的步骤: 1. 创建一个 JSON 文件,其中包含您要设置的 mapping 信息。例如,以下是一个包含 mapping 信息的示例文件: ``` { "properties": { "user_id": { "type": "integer" }, "user_name": { "type": "text" }, "user_email": { "type": "keyword" } } } ``` 在上面的示例中,我们定义了一个名为 `user` 的 index,其中包含三个字段:`user_id`、`user_name` 和 `user_email`。 2. 使用 curl 命令向 Elasticsearch 中的 index 设置 mapping。以下是一个示例命令: ``` curl -XPUT -H "Content-Type: application/json" http://localhost:9200/<index_name>/_mapping -d @<path_to_mapping_file> ``` 在上面的命令中,您需要将 `<index_name>` 替换为您要设置 mapping 的 index 名称,将 `<path_to_mapping_file>` 替换为包含 mapping 信息的 JSON 文件的路径。 例如,如果您要将上面的 mapping 设置到名为 `user` 的 index 中,您可以使用以下命令: ``` curl -XPUT -H "Content-Type: application/json" http://localhost:9200/user/_mapping -d @mapping_file.json ``` 在上面的命令中,`mapping_file.json` 是包含 mapping 信息的 JSON 文件的名称。 3. 确认 mapping 设置成功。您可以使用以下命令来检查 index 的 mapping 设置: ``` curl -XGET http://localhost:9200/<index_name>/_mapping ``` 在上面的命令中,您需要将 `<index_name>` 替换为您要检查 mapping 的 index 名称。 例如,如果您要检查名为 `user` 的 index 的 mapping,您可以使用以下命令: ``` curl -XGET http://localhost:9200/user/_mapping ``` 以上是使用 curl 命令设置 Elasticsearch 中的 mapping 的步骤。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值