当前位置: 首页 > 知识库问答 >
问题:

Elasticsearch嵌套映射

阳念
2023-03-14

我用下面的方法尝试了嵌套映射。

PUT /xyz
{
  "mappings": {
    "logs": {
      "properties": {
        "startTime": {"type": "date",
                      "format": "HH:mm:ss" 
                     },
        "stopTime":  {"type": "date",
                      "format": "HH:mm:ss"
                     },
        "acceptedRequests": {"type": "integer"},
        "clientErrors": {"type": "integer"},
        "serverErrors": {"type": "integer"}
                   },
        "predicted":{"type":"nested",
          "properties":{
          "predict1": {"type":"nested",
            "properties":{
            "acceptedRequests":{"type":"integer"},
            "clientErrors": {"type": "integer"},
            "serverErrors": {"type": "integer"}
                        }
                      },
          "predict2": {"type":"nested",
            "properties":{
            "acceptedRequests":{"type":"integer"},
            "clientErrors": {"type": "integer"},
            "serverErrors": {"type": "integer"}                              }
                       },
          "predict3": {"type":"nested",
            "properties":{
            "acceptedRequests":{"type":"integer"},
            "clientErrors": {"type": "integer"},
            "serverErrors": {"type": "integer"}
                         }
                       }
                      }
                     }   
              }
}
}

我在声明“root_cause”时出错:[{“type”:“mapper_parsing_exception”,“reason”:“root映射定义有不支持的参数:[type:nested]。”

感谢您的帮助。

共有1个答案

段干恺
2023-03-14

您会得到错误,因为属性标记在“预测”属性之前关闭。使用下面的映射来纠正错误

{
   "mappings":{
      "logs":{
         "properties":{
            "startTime":{
               "type":"date",
               "format":"HH:mm:ss"
            },
            "stopTime":{
               "type":"date",
               "format":"HH:mm:ss"
            },
            "acceptedRequests":{
               "type":"integer"
            },
            "clientErrors":{
               "type":"integer"
            },
            "serverErrors":{
               "type":"integer"
            }
         ,
         "predicted":{
            "type":"nested",
            "properties":{
               "predict1":{
                  "type":"nested",
                  "properties":{
                     "acceptedRequests":{
                        "type":"integer"
                     },
                     "clientErrors":{
                        "type":"integer"
                     },
                     "serverErrors":{
                        "type":"integer"
                     }
                  }
               },
               "predict2":{
                  "type":"nested",
                  "properties":{
                     "acceptedRequests":{
                        "type":"integer"
                     },
                     "clientErrors":{
                        "type":"integer"
                     },
                     "serverErrors":{
                        "type":"integer"
                     }
                  }
               },
               "predict3":{
                  "type":"nested",
                  "properties":{
                     "acceptedRequests":{
                        "type":"integer"
                     },
                     "clientErrors":{
                        "type":"integer"
                     },
                     "serverErrors":{
                        "type":"integer"
                     }
                  }
               }
            }
         }
         }
      }
   }
}
 类似资料:
  • 我必须使用elasticsearch和python为需要索引的json数据创建索引。例如,我有一个嵌套数组[[39.909971141540645,1452077285.150548,1452077286.196072,1.0455241203308105]]我需要为这个数组定义一个映射,比如第一个字段是count,第二个字段是start_time,end_time,duration。请帮助说明如

  • 我正在使用弹性搜索和Spring数据弹性。并尝试使用多重搜索。问题是在使用类字段搜索时,它不适用于嵌套字段。我的映射如下所示 我有一个带有searchQuery的endpoint,比如: 问题是查询不适用于嵌套字段。有什么建议吗? 使现代化 事实上,嵌套对象可以查询为 有没有两个类似的问题

  • 随着ElasticSearch计划删除映射类型,这是否也意味着不再使用嵌套文档和嵌套查询?ElasticSearch将如何支持无类型上下文中的嵌套对象查询? 我正在考虑的功能是能够只返回匹配搜索条件的嵌套数组中的命中。 编辑1:ElasticSearch版本6中的映射查询示例 ElasticSearch 6映射 ElasticSearch 6查询

  • 我用的是Protobuf 3。从文档来看,似乎无法定义嵌套贴图: 我正在尝试创建一种消息类型来表示期权链的定价信息(出价和要价)。对于那些不熟悉这些金融工具的人,基本上我有一套“到期日期(YYYYMMDD)”。在每个过期日期中,我都有一组“strikes(float number;如果需要,可以用字符串表示,我同意)”。在每次行使中,我有两个期权,一个“看跌”和一个“看涨”(这被称为期权的“右”)

  • 我尝试使用MapStruct编写映射器类,如下所示: 目前它显示了“未知属性”“customer.customerid”和“usertypes.usertype.userid”等错误。有人能帮我用MapStruct映射所有这些元素吗? 问题2:我们如何绘制跟踪图?1)customerId usertypes->user->userid 2)pdtPrice offers->OffersType->

  • 问题内容: 我正在尝试在Elasticsearch中进行嵌套排序,但到目前为止没有成功。 我的数据结构: 我想根据文档中第一作者的姓氏对文档进行排序。 使用的映射: 使用SearchRequestBuilder(JAVA)进行排序: 这行得通,但没有给出想要的结果(例如,首先是“叫卖”,然后是“罗杰”)。 我错过了什么吗?有没有办法表明Elasticsearch访问数组authorList的ind