因為使用的是容器,所以,這里不使用文件的方式。目前,有一個疑問,發現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