ElasticSearch Relation

research keyword (ElasticSearch+)

  • relationship
  • one to many
  • manay to many
  • denormalize
  • deep nested
  • data modling

review

  • parent/child join
  • nested
    • 设计
      • 从某一种content作为主体,把和这个content关联的其他content,作为该content的子字段形成json
        • 1:1,contentA和contentB,以contentA作为主体,把contentB的数据作为contentA的一个object字段存起来
        • 1:n,talent和experience,talent作为主体,把experience的数据作为talent的一个array objcet字段存起来
        • n:1,experience和company,experience作为主体,把company的数据作为experience的一个object字段存起来
        • n:n,company和industry,company作为主体,把industry的数据作为company的一个array objcet字段存起来
        • n:n:n...,同上
      • 样例数据
    • 性能测试
      • 16000条nested数据
      • size: 178Mi (178Mi)
      • docs: 1,265,472 (1,293,084)
      • search性能还是50ms以下,同时update 50个doc大概花费200ms,1000个doc大概花费600ms
    • titanhouse tp/cp也是同样的使用方法,把titan作为主体进行index,下面挂住company、experience字段,以及额外的一些计算字段
    • 使用nested做es中关系的表示应该没有太大问题,场景复杂了或者nested嵌套层数多了需要对数据结构做额外优化
    • 优点
      • 使用简单,用objce或者object[]作为子field,天然代表了关联关系
    • 缺点
      • 数据冗余较多,占用存储空间更大
      • 如果nested层数嵌套过深,进行reindex时(document更新),花费时间更多,index性能不如parent/child join的方式,https://www.elastic.co/blog/managing-relations-inside-elasticsearch
      • 如果处于nested较底层的数据更新,那么关联的主document均需要更新
        • talent -> experience -> company -> industry

reference

relation

denormalize/denormalization

nested

join/parent+children

type

es vs solr join

results matching ""

    No results matching ""