Elasticsearch动态映射对比Solr动态场

Elasticsearch dynamic mapping compared to Solr dynamic field

在 Solr 中,我可以定义动态字段并将其绑定到特定数据类型。在以下示例中,索引文档中以 "dt" 结尾的所有字段都将被索引为 long. <dynamicField name="*_dt" stored="true" indexed="true" type="long" multiValued="true"/>

在 ElasticSearch 中,知道字段名称后,我可以使用 "mappings" 中的 "properties" 子节点将字段索引到特定类型。 "properties": { "msh_datetimeofmessage_hl7_dt": { "type": "date", "format": "YYYYMMddHHmmss" },

我尝试了以下操作并尝试使用模板,但未成功。 "properties": { "*_dt": { "type": "date", "format": "YYYYMMddHHmmss" },

ElasticSearch 是否提供与上述 Solr 相同的功能?

提前致谢。

我想您可能正在寻找 dynamic templates 提供的功能。除非我弄错了,否则你的映射看起来像这样(主要是从链接页面借来的)。

PUT /my_index
{
"mappings": {
    "my_type": {
        "dynamic_templates": [
            { "my_date_template": {
                  "match":              "*_dt", 
                  "mapping": {
                      "type":           "date",
                      "format": "YYYYMMDDHHmmss"
                  }
            }}
        ]
}}}