因为使用的是容器,所以,这里不使用文件的方式。目前,有一个疑问,发现bulk进入的数据,字段类型是没有问题的,之前没有设置mapping的情况下。
1.批量导入
Bulk:ES提供了⼀个叫 bulk 的API 来进⾏批量操作
2.示例
POST /_bulk
{"index": {"_index": "book","_type": "_doc","_id": 1}}
{"name": "权⼒的游戏"}
{"index": {"_index": "book","_type": "_doc","_id": 2}}
{"name": "疯狂的⽯头"}
效果:
{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 2,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "book",
"_type" : "_doc",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"name" : "权⼒的游戏"
}
},
{
"_index" : "book",
"_type" : "_doc",
"_id" : "2",
"_score" : 1.0,
"_source" : {
"name" : "疯狂的⽯头"
}
}
]
}
}
3.截图

二:测试上面的疑问
1.测试
PUT /test/_doc/1
{
"name":"tom",
"age":10
}
GET /test/_mapping
结果:
{
"test" : {
"mappings" : {
"properties" : {
"age" : {
"type" : "long"
},
"name" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
}
}
2.解释
这是es中的 multi-fields.:https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-fields.html

3.官网的说明
It is often useful to index the same field in different ways for different purposes.
This is the purpose of multi-fields.
For instance, a string field could be mapped as a text field for full-text search, and as a keyword field for sorting or aggregations