Java 调用ES动态字段检索

{ "dynamic_templates": [ { "model_data_fields": { "path_match": "modelData.**", "mapping": { "type":

{
    "dynamic_templates": [
      {
        "model_data_fields": {
          "path_match": "modelData.**",
          "mapping": {
            "type": "text",
            "analyzer": "ik_smart",
            "search_analyzer": "ik_max_word",
            "fields": {
              "raw": {
                "type": "keyword"
              }
            }
          }
        }
      },
      {
        "model_data_time_fields": {
          "path_match": "modelData.**Time",
          "mapping": {
            "type": "date",
            "format": "date_optional_time||epoch_millis||date_hour_minute_second||date_hour_minute_second_fraction||date_hour_minute_second_millis||date_hour_minute",
            "fields": {
              "raw": {
                "type": "keyword"
              }
            }
          }
        }
      }
    ],
    "properties": {
        "authList": {
            "type": "text"
        },
        "dataId": {
            "type": "keyword"
        },
        "labelList": {
            "type": "text"
        },
        "modelData": {
            "type": "object"
        },
        "recommendDataJson": {
            "type": "keyword"
        },
        "modelId": {
            "type": "keyword"
        },
        "model": {
            "type": "keyword"
        }    
    }
}

dynamic_templates可以匹配当前字段或者类型进行动态增加字段内容

比如目前定义匹配modelData.**就会匹配静态定义的modelData内的值并当前text对象存储,用于后面检索,时间类型也是类似

评论