映射的介绍和使用
-
新增
- 请求
curl -X PUT "http://172.25.45.150: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 }
-
获取索引mapping
-
请求
curl -X GET "http://172.25.45.150:9200/nba/_mapping"
-
响应
{ "nba": { "mappings": { "properties": { "jerse_no": { "type": "keyword" }, "name": { "type": "text" }, "play_year": { "type": "keyword" }, "position": { "type": "keyword" }, "team_name": { "type": "text" } } } } }
-
-
获取所有mapping
-
请求
curl -X GET "http://172.25.45.150:9200/_mapping"
-
-
修改mapping
-
请求
curl -X POST "http://172.25.45.150: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" }, "contry":{ "type":"keyword" } } } '
-
响应
{ "acknowledged": true }
-
type的介绍
- text : 表示字段是使用全文索引,可以进行分词,例如 ”我是一名学生“ 他会被分成 我、是、学生 等。
- keyword:表示是一个关键字,不会被分词。