elasticsearch - 如何在Elasticsearch中设置多字段值

标签 elasticsearch

我有下面的映射-

{
    "mappings": {
        "my_type": {
            "properties": {
                 "status": {
                      "type": "text",
                      "fields": {
                         "code": {
                            "type": "keyword"
                         }
                      }
               }    
            }   
        }    
    }
}

我想为状态和代码设置值,例如-

status - CRITICAL
status.code - 10



我该怎么办?

最佳答案

你不能那样做。您需要使用object类型而不是多字段

{
  "mappings": {
    "my_type": {
      "properties": {
        "status": {
          "type": "object",
          "properties": {          
            "name": {
              "type": "keyword"
            },
            "code": {
              "type": "integer"
            }
          }
        }
      }
    }
  }
}

然后您就可以设置
status.name - CRITICAL 
status.code - 10

关于elasticsearch - 如何在Elasticsearch中设置多字段值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43936676/

相关文章:

python - 如何禁用查询缓存?

apache-spark - Spark ElasticSearch EsHadoopIllegalArgumentException 无法找到具有有效 URI 的 keystore

java - ElasticSearch:脚本内联减去日期

mongodb - 如何将Spring数据Elasticsearch与MongoDB同步?

elasticsearch ngram 分析器/tokenizer 不工作?

apache-spark - 如何用Spark写入远程Elasticsearch节点?

elasticsearch - ElasticSearch-卸载版本6.4.3,安装版本6.4.2-Linux Ubuntu

elasticsearch - 在时间范围内查找相同的文本

elasticsearch - 为什么@在 Elasticsearch 中不匹配query_string查询?

sql - 如何使用 elasticsearch 获得 SQL 中的 JOIN 功能?