elasticsearch 在索引ElasticSeacrh中禁用“object”类型的索引参数

qybjjes1  于 4个月前  发布在  ElasticSearch
关注(0)|答案(1)|浏览(63)

我使用ElasticSearch 8.6.2来存储自定义日志,我构建了一个Java对象,并使用RestHighLevelClient将其保存到ELC中。我在ELK中保存的类:

public class DetailedLogModel {

    private Map<String, Object> variables;
    private String accountId;
    private String event;
    private String trackId;
    private String requestId;
    private String processInstanceId;
    private String contextPath;
    private String confId;
    private LocalDateTime dateTime;
    private String componentId;
    private String componentName;
    private String parentActionId;
    private String parentProcessInstanceId;
    private String actionId;
    private ActionDetailLogType actionType;
    private String uri;
    private String method;

字符串
我对除了“变量”之外的所有字段的自动索引感到满意,因为它可以存储无限数量的其他字段,这是一个问题,我如何解决它?一切都将有所帮助,甚至是REST请求指定body的示例。我尝试了使用此配置创建索引的选项

{
  "mappings": {
    "properties": {
      "variables": {
        "type": "object",
        "index": false, 
        "store": true     
      }
    
    }
  }
}


但我有错误

{
    "error": {
        "root_cause": [
            {
                "type": "mapper_parsing_exception",
                "reason": "Mapping definition for [variables] has unsupported parameters:  [index : false] [store : true]"
            }
        ],
        "type": "mapper_parsing_exception",
        "reason": "Failed to parse mapping: Mapping definition for [variables] has unsupported parameters:  [index : false] [store : true]",
        "caused_by": {
            "type": "mapper_parsing_exception",
            "reason": "Mapping definition for [variables] has unsupported parameters:  [index : false] [store : true]"
        }
    },
    "status": 400
}


而且它只适用于带有关键字和文本类型的字段。也许有人会告诉你如何查看索引字段的列表?我使用的是GET http://127.0.0.1:9200/detail_log_2023-11-23/_mapping。但这并不反映现实,因为变量字段无论如何都是索引的。

hivapdat

hivapdat1#

您需要使用特定于对象字段的enabled mapping parameter

{
  "mappings": {
    "properties": {
      "variables": {
        "type": "object",
        "enabled": false  
      }
    
    }
  }
}

字符串

相关问题