Mapping设置

image.png

  • date_detection:建议为false

    类型选择

    image.png

    是否需要检索【enable/index/index_options】

    image.png
    4.Mapping

    index enabled 区别

关于es映射mapping中的enabled,store,index参数的理解 - Elastic 中文社区

是否聚合分析【norms/doc_values/field_data】

image.png
norms 是一个用来计算文档/字段得分(Score)的”调节因子”。
对于 text 类型的字段而言,默认开启了norms,而 keyword 类型的字段则默认关闭了norms
image.png

  • doc_values:默认true
  • fielddata:默认false

image.png

是否另行存储【store/coerce/multifields】

image.png
image.png

Mapping样例(使用store优化_source)

不聚合字段

  • 不需要聚合的doc_values:false

    优化大字段传输

  • _source设置为enable:false

  • 字段store:true
  • 查询使用stored_fields
    • 我们给某些字段的store属性设置为true,在查询时,请求中可以携带stored_fields参数,指定某些字段,最后,这些字段会被包含在返回的结果中。

image.png
image.png

关联关系

image.png

Nested Object解决什么问题

image.png
搜索结果和想象的不一样:
image.png
原理:
image.png

Nested Object

image.png

Nested Object查询方式

image.png

Nested Object存储方式

image.png

Parent Child

mapping
image.png

  • type:join

添加父文档
image.png
添加子文档
image.png

Parent Child查询语法

image.png
image.png

parent_id

所有parent_id的子文档
image.png
根据parent_id查指定子文档
image.png

has_child

image.png

has_parent

image.png

Nested Object对比Parent Child

image.png

Reindex

image.png

_update_by_query【在现在索引上重建】

image.png
image.png

  • 重建“凯”“悦”的索引。

    Reindex【其他索引上重建】

    image.png
    image.png

    异步reindex

    image.png

    跨集群reindex

    image.png

建议

模型版本管理

image.png

防止字段过多

image.png

通过key、value来解决字段过多问题

Mapping

image.png

数据样例

image.png

查询方式

image.png