5

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.

1 Answer 1

7

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"
          }
        }
      }
    }
  }
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. This was typing issue. I got the mapping and after reading Elastic Search documentation I realized that we can not update mapping for an already created index. We need to delete the previous mapping first and then create new mapping for this index. If there is any other way around please share. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.