elasticsearch 使用不同的文档类型在elasticsearch中创建索引,elasticsearch,indexing,full-text-search,elastic-stack,elasticsearch,Indexing,Full Text Search,Elastic Stack" /> elasticsearch 使用不同的文档类型在elasticsearch中创建索引,elasticsearch,indexing,full-text-search,elastic-stack,elasticsearch,Indexing,Full Text Search,Elastic Stack" />

elasticsearch 使用不同的文档类型在elasticsearch中创建索引

elasticsearch 使用不同的文档类型在elasticsearch中创建索引,elasticsearch,indexing,full-text-search,elastic-stack,elasticsearch,Indexing,Full Text Search,Elastic Stack,我需要索引“客户”实体的弹性。我的对象“CLIENT”person由几个片段(JSON文档)组成,如 所以我的索引必须存储所有这些段(JSON文档)。然后我必须通过不同的字段和段组合进行搜索,例如:搜索COMMON.firstname、COMMON.lastname、EDUCATION.field1、EDUCATION.field2中的“university”。我是否可以将搜索结果作为包含所有段的客户端列表返回?我想说的是,文档可以是这样的 { ...common properties,

我需要索引“客户”实体的弹性。我的对象“CLIENT”person由几个片段(JSON文档)组成,如


所以我的索引必须存储所有这些段(JSON文档)。然后我必须通过不同的字段和段组合进行搜索,例如:
搜索COMMON.firstname、COMMON.lastname、EDUCATION.field1、EDUCATION.field2中的“university”。我是否可以将搜索结果作为包含所有段的客户端列表返回?我想说的是,文档可以是这样的

{
  ...common properties,
  "education": {
    ...education properties
  },
  "job": {
    ...job properties
  }
}
为了索引此类文档,您可以执行下一个查询(如果不存在新索引,将自动创建新索引)

其中,client是索引名,doc是类型,1是新文档的id

然后,您可以通过执行

GET /client/doc/_search
为了搜索,您可以执行(这也将返回最多10个文档,因为10是默认值)


如果要显式指定所有或部分属性的数据类型,请查看。否则,将根据值分配默认数据类型,如字符串值的“文本”等。

非常感谢您的回复。但你能澄清一下,这仅仅是一种解决方案吗?因为我有大约50-100个段,其中一些很少更改,一些经常会更改很多次,所以我必须更新整个文档包含100个段,即使一个段中的一个字段每小时更新一次,如果我有500000个客户端,那么我将每小时更新500000个完整记录Relatic不更新文档,它删除现有的一个,然后索引一个新的。然而,从用户的角度来看,弹性支持部分更新。这意味着您可以提交部分文档,该文档将与现有文档合并。是的,这将是对文档的完全重写,但您不需要提交整个文档。如果您担心数据一致性,那么请记住,弹性不提供“事务”功能,因此您可以考虑传统的RDB。
PUT /client/doc/1
{
  "firstName": "...",
  "lastName": "...",
  ...other common properties,
  "education": {
    ...education properties
  },
  "job": {
    ...job properties
  }
}
GET /client/doc/_search
GET /client/doc/_search
{
  "query": {
    "query_string" : {
      "query" : "firstName:university OR lastName:university OR education.field1:university OR education.field1:university",
      "default_field" : "content"
    }
  }
}