【问题标题】:What is the replacement for FielddataLoading.Eager option in Elasticsearch mapping?Elasticsearch 映射中 FielddataLoading.Eager 选项的替代品是什么?
【发布时间】:2023-03-15 09:38:01
【问题描述】:

我正在将应用程序从 Elasticsearch 2.3 升级到 7.9。我正在使用 NEST 客户端版本 7.11.1,它显示与 ES 7.9 兼容。我们使用的是 7.9,因为这是我们正在使用的 AWS 服务器上可用的最新版本。

旧应用有以下字段映射:

.String(s => s
    .Name(f => f.PartDescription)
    .Analyzer(Analyzers.DescriptionAnalyzer)
    .Fielddata(descriptor => descriptor.Loading(FielddataLoading.Eager)));

我在新版本中使用以下映射来替换它:

.Text(t => t
    .Name(ep => ep.PartDescription)
    .Analyzer(Analyzer.DescriptionAnalyzer)
    .Fielddata(true))

我看到在新版本中 Fielddata 的唯一选项是布尔值。缺少 Eager 和其他选项。

Fielddata(true) 是否适合升级?

【问题讨论】:

    标签: elasticsearch nest


    【解决方案1】:

    fielddata 上的布尔值确定是否为该字段启用fielddatafielddata 在执行聚合、排序和编写脚本时使用,并按需加载到堆、字段数据缓存中(非急切加载)。

    通常用于text datatype fields, you don't want fielddatatext 数据类型经过分析,生成的标记存储在倒排索引中。当fielddata 设置为true 时,倒排索引会根据需要不倒排以生成加载到堆中的柱状结构,以服务于text 字段上的聚合、排序和脚本。文本分析通常会产生许多标记,这些标记很好地服务于全文搜索的目的,但不能很好地服务于聚合、排序和编写脚本的目的。使用 许多 个标记和 许多 个并发聚合,堆内存可以快速增长,从而施加 GC 压力。因此,text 数据类型字段的默认设置是将 fielddata 设置为 false,如果您知道自己在做什么,则将其设置为 true

    不要在text 数据类型字段上将fielddata 设置为true,如果该字段是您想要用于聚合、排序和脚本的字段,一个好的方法是设置use multi-fields and also map the field as a keyword datatype,并以@ 为目标987654340@多字段用于此目的。

    【讨论】:

    • 这很简单!我从这些字段中删除了 Fielddata(true) 设置,一切仍然有效。我不确定为什么旧应用程序的开发人员使用该设置,但它似乎是多余的,因为这些字段不用于排序或聚合。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-02
    • 2010-10-01
    • 2019-02-22
    • 2011-05-07
    • 2012-04-24
    • 2019-12-03
    • 2010-09-17
    相关资源
    最近更新 更多