ElasticSearch PutMapping API:MapperParsingException解析后,根类型映射不为空 [英] ElasticSearch PutMapping API: MapperParsingException Root type mapping not empty after parsing

查看:258
本文介绍了ElasticSearch PutMapping API:MapperParsingException解析后,根类型映射不为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的本地实例ES 1.3.4和JDBC For MySql中有一条河1.3.4.4



这条河在ES中正常工作并导入数据。问题我面临的是我的一个字段是一个文本字段,并在其中有空格。例如实时计算器。 ES将其作为实时,时间和计算器进行索引,而不是实时计算器。



所以我使用下面提到的JSON创建映射: / p>

  {
sale_test:{
properties:{
Client {
index:not_analyzed,
type:string
},
OfferRGU:{
type:long
},
SaleDate:{
format:dateOptionalTime,
type:date
},
状态:{
type:string
}
}
}
}

和命令:

  curl -XPUT http:// localhost:9200 / my_index / _mapping / my_type 

但是我得到以下提到的错误:

 > {error:MapperParsingException [
>解析后的根类型映射不为空]剩余字段:[sale_test:
> {properties = {Client = {type = string,index = not_analyzed}
> OfferRGU = {type = long},SaleDate = {type = date,format = dateOptionalTime},
> State = {type = string}}}]],status

当我尝试使用以下命令查看当前的映射:

  curl -XGET http:// localhost:9200 / dgses / sale_test_river / _mapping 

只有这样: {}



感谢您的帮助。 b $ b

解决方案

您的类型不一致,API调用中的类型是 my_type

  curl -XPUT http:// localhost:9200 / my_index / _mapping / my_type 

然后在JSON消息中变为 sale_test



具有一致的类型可以解决您的问题:

  curl -XPUT http:// localhost:9200 / my_index / _mapping / sale_test -d'
{
sale_test:{
properties:{
Client:{type:string,index:not_analyzed},
OfferRGU:{type :long},
SaleDate:{type:date,format:dateOptionalTime},
State:{type:string}
}
}
}'






这里您同时拥有新的索引和新类型

  curl -XGET http:// localhost:9200 / dgses / sale_test_river / _mapping 

更正索引和类型给我:

  curl -XGET http:// localhost:9200 / my_index / sale_test / _mapping?漂亮
{
myindex:{
mappings:{
sale_test:{
properties:{
Client {
type:string,
index:not_analyzed
},
OfferRGU:{
type:long
},
SaleDate:{
type:date,
format:dateOptionalTime
},
状态:{
type:string
}
}
}
}
}
}


I have a River on my local instance of ES 1.3.4 and JDBC For MySql 1.3.4.4

This river is working fine and importing data in ES. Problem I am facing that one of my field is a text field and has spaces in it. For example 'Real Time Calculator'. ES is indexing it as 'real', 'time' and 'calculator' instead of 'Real Time Calculator'.

So I am creating mapping using below mentioned JSON:

{
    "sale_test": {
        "properties": {
            "Client": {
                "index": "not_analyzed",
                "type": "string"
            },
            "OfferRGU": {
                "type": "long"
            },
            "SaleDate": {
                "format": "dateOptionalTime",
                "type": "date"
            },
            "State": {
                "type": "string"
            }
        }
    }
}

and Command:

curl -XPUT http://localhost:9200/my_index/_mapping/my_type

But I am getting below mentioned error:

> {"error":"MapperParsingException[Root type mapping not empty after
> parsing! Remaining fields:   [sale_test :
> {properties={Client={type=string, index=not_analyzed},
> OfferRGU={type=long}, SaleDate={type=date, format=dateOptionalTime},
> State={type=string}}}]]","status":400}

When I try to view current mapping using below mentioned command:

curl -XGET http://localhost:9200/dgses/sale_test_river/_mapping

I get only this: {}

Thanks for your help.

解决方案

Your type is not consistent, in the API call the type is my_type

curl -XPUT http://localhost:9200/my_index/_mapping/my_type

then it becomes sale_test in the JSON message.

Having a consistent type will fix your problem:

curl -XPUT http://localhost:9200/my_index/_mapping/sale_test -d '
    { 
     "sale_test": { 
       "properties": { 
         "Client": {"type": "string", "index": "not_analyzed" }, 
         "OfferRGU": { "type": "long" }, 
         "SaleDate": { "type": "date", "format": "dateOptionalTime" },
         "State": { "type": "string" }
         } 
       } 
    }'


Here you have both a new index and a new type:

curl -XGET http://localhost:9200/dgses/sale_test_river/_mapping

Correcting the index and type gives me:

curl -XGET http://localhost:9200/my_index/sale_test/_mapping?pretty
{
  "myindex" : {
    "mappings" : {
      "sale_test" : {
        "properties" : {
          "Client" : {
            "type" : "string",
            "index" : "not_analyzed"
          },
          "OfferRGU" : {
            "type" : "long"
          },
          "SaleDate" : {
            "type" : "date",
            "format" : "dateOptionalTime"
          },
          "State" : {
            "type" : "string"
          }
        }
      }
    }
  }
}

这篇关于ElasticSearch PutMapping API:MapperParsingException解析后,根类型映射不为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆