下载弹性搜索文档

时间:2016-08-22 13:16:06

标签: elasticsearch

我正在阅读elastic documentation并且在理解文档和索引的概念方面遇到了一些麻烦。

  

Elasticsearch是面向文档的,意味着它存储整个   对象或文件。

他们提供了这个例子:

curl -XPUT "localhost:9200/megacorp/empolyee/3/?pretty" -d '                                                                                                    
{                                                                                                

    "first_name": "Douglas",
    "last_name": "Fir",
    "age": 35,
    "about": "I like to build cabinets",
    "interest": ["forestry"]
}
'

据我所知,megacorp是此处的索引。但是文件是什么?编号为3的员工是否为文件?或者,由路径megacorp/employee存储的所有员工组成一个单独的文档?

1 个答案:

答案 0 :(得分:1)

使用您的示例:

curl -XPUT "localhost:9200/megacorp/employee/3/?pretty" -d '                                                                                                    
{                                                                                                

    "first_name": "Douglas",
    "last_name": "Fir",
    "age": 35,
    "about": "I like to build cabinets",
    "interest": ["forestry"]
}'
  • megacorp是索引
  • employee是映射类型(即所有员工字段及其类型的定义)
  • 3是员工的ID
  • {"first_name": "Douglas", ..., "interest": ["forestry"]}是包含员工3
  • 所有字段的文档

基本上,如果我们绘制与传统RDBMS并行:

  • megacorp将是数据库名称
  • employee将是包含所有员工记录(即员工架构)的数据库表
  • 3将成为员工记录的主键
  • {"first_name": "Douglas", ..., "interest": ["forestry"]}将包含员工3
  • 的所有字段的记录
相关问题