ElasticSearch创建索引详细说明

例子

http://192.168.142.128:9201/haoke
{
  "settings": {
    "index": {
      "number_of_shards": 6,
      "number_of_replicas": 1
    }
  },
  "mappings": {
    "house": {
      "dynamic": false,
      "properties": {
        "title": {
          "type": "text",
          "analyzer": "ik_max_word"
        },
        "image": {
          "type": "keyword",
          "index": false
        },
        "orientation": {
          "type": "keyword",
          "index": false
        },
        "houseType": {
          "type": "keyword",
          "index": false
        },
        "rentMethod": {
          "type": "keyword",
          "index": false
        },
        "time": {
          "type": "keyword",
          "index": false
        },
        "rent": {
          "type": "keyword",
          "index": false
        },
        "floor": {
          "type": "keyword",
          "index": false
        }
      }
    }
  }
}

http://192.168.142.128:9201/haoke:表示索引的名字为haoke

{
  "settings": {              
    "index": {          索引
      "number_of_shards": 6,        指定分片的数量为6
      "number_of_replicas": 1       指定每个分片拥有的副本数量 为1
    }
  },
  "mappings": {        在mappings中对每个字段进行设置
    "house": {           指定type的名字为house
      "dynamic": false,    下面单独说明
      "properties": {
        "title": {
          "type": "text",      设置字段的类型为text表示可以被索引的,可以进行分词的字段
          "analyzer": "ik_max_word"    指定分词器为ik_max_word
        },
        "image": {
          "type": "keyword",      设置字段的类型为keyword表示不能进行分词
          "index": false     index设置为false表示不能通过这个字段来查询数据
        }
      }
    }
  }
}

dynamic 

  • dynamic 参数来控制字段的新增 
  • true:默认值,表示允许选自动新增字段 
  • false:不允许自动新增字段,但是文档可以正常写入,但无法对字段进行查询等操作 
  • strict:严格模式,文档不能写入,报错 

index 

  • index参数作用是控制当前字段是否被索引,默认为true,false表示不记录,即不可被搜索。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值