Elasticsearch学习(二)

Elasticsearch填充

创建索引

PUT - http://localhost:9200/schools

响应
在这里插入图片描述

创建映射和添加数据

映射参数说明:

1.type:Elasticsearch 中支持的数据类型非常丰富。以下是数据类型:

  • String类型包含text(可分词)keyword(不可分词)
  • Numerical类型分为两类基本数据类型(long、integer、short、byte、double、float、half_float)和浮点数的高精度类型scaled_float
  • Date日期类型
  • Array数组类型
  • Object对象

2.index:是否索引,默认为true。也就是说index设为true的时候才可以被搜索
3.store:是否将数据进行独立存储,默认为 false。原始的文本会存储在_source 里面,默认情况下其他提取出来的字段都不是独立存储的,是从_source 里面提取出来的。当然你也可以独立的存储某个字段,只要设置"store": true 即可,获取独立存储的字段要比从_source 中解析快得多,但是也会占用更多的空间,所以要根据实际业务需求来设置。
4.analyzer:分词器,这里的 ik_max_word 即使用 ik 分词器

创建映射(第一种)
PUT - http://localhost:9200/schools/_mapping

{
    "properties" : {
        "schoolname" : {
            "type" : "text",
            "index" : true
        },
        "tel" : {
            "type" : "text",
            "index" : true
        },
        "area" : {
            "type" : "double",
            "index" :true
        }
    }
}

响应
在这里插入图片描述

创建映射(第二种)
PUT - http://localhost:9200/schools

{
    "settings":{},
    "mappings":{
        "properties":{
            "name": {
                "type":"text",
                "index":true
            },
            "tel" : {
                "type":"text",
                "index":true
            },
            "area" : {
                "type":"double",
                "index":true
            }
        }
    }
}

在这里插入图片描述

添加数据

POST - http://localhost:9200/schools/_doc
{
    "name":"潘家园小学",
    "tel":"1822222222",
    "area":875.3
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值