Monday, April 11, 2016

Creating Mapping/Type in ElasticSearch

Basically two forms:

1. creating index while creating mapping

curl -XPUT localhost:9200/testIndex -d'
{
"mappings":{
"testType": {
    "properties": {
        "id": {
                "type": "string"
            },
            "xml": {
                "type" : "string", "index" : "no" , "include_in_all":"false"
            },
            "json": {
                "type": "nested"
            },
            "comment": {
                "type": "string"
            }
        }
    }
}
}'

2. creating or updating mapping in existing index

curl -XPUT localhost:9200/testIndex/_mapping/testType2 -d'
{

    "properties": {
        "id": {
                "type": "string"
            },
            "xml": {
                "type" : "string", "index" : "no" , "include_in_all":"false"
            },
            "json": {
                "type": "nested"
            },
            "comment": {
                "type": "string"
            }
        }

}'