es的文檔id生成方式可以是 自動的uuid,也可以是自定義的id,可以用業務中的id字段進行映射
自動的id,URL安全,base64編碼,GUID,如下:
POST /test_index/test_type
{ "test_content": "my test" }
手動的就靠自己定義
PUT /test_index/test_type/2 { "test_content": "my test" }
那么使用logstash抽取數據是怎么做映射的?配置文件如下:
input { elasticsearch { hosts => ["192.168.0.1:9200"] index => "ddd" query => '{ "query": {"match_all" : {} } }' size => 1000 scroll => "1m" codec => "json" docinfo => true } } output { stdout { codec => rubydebug } elasticsearch { hosts => ["192.168.0.2:9200"] document_type => "messages" document_id => "%{id}" index => "ddd" } }
document_id => "%{id}" 指定 文檔id 使用自己定義json 文件中的id 號映射。