您的位置:首页 > 其它

elasticsearch 创建type及插入数据

2016-05-21 11:04 405 查看
创建 type ("store":"yes")

PUT my_index

{

  "mappings": {

    "type_one": {

      "properties": {

        "text": { 

          "type": "string",

          "analyzer": "standard"

        }

      }

    },

    "type_two": {

      "properties": {

        "text": { 

          "type": "string",

          "analyzer": "standard"

        }

      }

    }

  }

}

PUT my_index/_mapping/type_one 

{

  "properties": {

    "text": {

      "type": "string",

      "analyzer": "standard",

      "search_analyzer": "whitespace"

    }

  }

}

PUT my_index/_mapping/type_one?update_all_types 

{

  "properties": {

    "text": {

      "type": "string",

      "analyzer": "standard",

      "search_analyzer": "whitespace"

    }

  }

}

//测试

{

  "properties": {

    "name": {

      "analyzer": "standard",

      "store": true,

      "type": "string"

    },

    "text": {

      "analyzer": "standard",

      "store": true,

      "type": "string"

    },

    "ziduan": {

      "search_analyzer": "ik",

      "analyzer": "standard",

      "type": "string"

    },

    "title": {

      "analyzer": "standard",

      "store": true,

      "type": "string"

    },

    "datt": {

      "format": "yyyy/mm/dd",

      "store": true,

      "type": "date"

    }

  }

}

{

  "name": "名称",

  "text": "文本",

  "ziduan": "字段",

  "title": "标题",

  "datt": "2016/03/04"
}
https://www.elastic.co/guide/en/elasticsearch/reference/2.2/indices-put-mapping.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: