1. 编写索引内容

  节点解释:

  settings:配置信息

  "number_of_replicas": 0  不需要备份(单节点的ElasticSearch使用)

  "mappings":  映射内容

  "dynamic":false  是否动态索引,这里使用的是false,表示索引的固定的,不需要修改。

  "properties": 属性结构内容

  "index":"true"  需要分词处理的结构

  type对应的数据类型,text文本(长字符串),integer数字,date时间,keyword单词

elasticsearch 6.X版本的索引文件

{
"settings":{
"number_of_replicas":
},
"mappings":{
"house":{
"dynamic":false,
"properties":{
"houseId":{"type":"long"},
"title":{"type":"text", "index":"true"},
"price":{"type":"integer"},
"area":{"type":"integer"},
"createTime":{"type":"date","format":"strict_date_optional_time||epoch_millis"},
"lastUpdateTime":{"type":"date", "format":"strict_date_optional_time||epoch_millis"},
"cityEnName":{"type":"keyword"},
"regionEnName":{"type":"keyword"},
"direction":{"type":"integer"},
"distanceToSubway":{"type":"integer"},
"subwayLineName":{"type":"keyword"},
"subwayStationName":{"type":"keyword"},
"tags":{"type":"text"},
"district":{"type":"keyword"},
"description":{"type":"text", "index":"true"},
"layoutDesc":{"type":"text", "index":"true"},
"traffic":{"type":"text", "index":"true"},
"roundService": {"type": "text", "index": "true"},
"rentWay":{"type":"integer"}
}
}
}
}

elasticsearch 7.X版本的索引文件

{
  "settings":{
    "number_of_replicas": 0
  },
  "mappings":{
    "dynamic":false,
    "properties":{
      "title":{"type":"text", "index":"true"},
      "price":{"type":"integer"},
      "area":{"type":"integer"},
      "createTime":{"type":"date","format":"strict_date_optional_time||epoch_millis"},
      "lastUpdateTime":{"type":"date", "format":"strict_date_optional_time||epoch_millis"},
      "cityEnName":{"type":"keyword"},
      "regionEnName":{"type":"keyword"},
      "direction":{"type":"integer"},
      "distanceToSubway":{"type":"integer"},
      "subwayLineName":{"type":"keyword"},
      "subwayStationName":{"type":"keyword"},
      "tags":{"type":"text"},
      "district":{"type":"keyword"},
      "description":{"type":"text", "index":"true"},
      "layoutDesc":{"type":"text", "index":"true"},
      "traffic":{"type":"text", "index":"true"},
   "roundService": {"type": "text", "index": "true"},
      "rentWay":{"type":"integer"}
    }
  }
}

2. 创建索引

  使用Postmen发送创建索引请求

  (1)地址栏后半段是索引名称

  (2)请求使用的PUT方式,选择Body,raw形式,采用JSON格式发送

  创建成功的显示结果:

{
"acknowledged": true,
"shards_acknowledged": true,
"index": "house"
}

  在ElasticSearch-Head里查看结果:

3. 创建索引时的报错:

  错误1:Root mapping definition has unsupported parameters

  原因:ElasticSearch7.X之后的版本默认不在支持指定索引类型,默认索引类型是_doc(隐含:include_type_name=false),所以在mappings节点后面,直接跟properties就可以了。

  

  问题2:Could not convert [title.index] to boolean

  原因:也是新版本的问题,之前版本的index属性写法是"analyze",现在只能设置true, false, "true","false"

												

ElasticSearch添加索引的更多相关文章

  1. ElasticSearch+Kibana 索引操作( 附源码)

    一 前言 ElasticiSearch 简介 ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口.Elastics ...

  2. ElasticSearch+Kibana 索引操作

    ElasticSearch+Kibana 索引操作 一 前言 ElasticiSearch 简介 ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户能力的全文搜索引 ...

  3. elasticsearch的索引自动清理及自定义清理

    近发现elasticsearch近期索引文件大的吓人,清理了下之前的索引文件,发现服务器性能大大的减轻了一半,想一直保留近一个月的索引文件,但是又不想每个月手动清楚,在此写了一个小脚本 查询索引: c ...

  4. ELK学习笔记之ElasticSearch的索引详解

    0x00 ElasticSearch的索引和MySQL的索引方式对比 Elasticsearch是通过Lucene的倒排索引技术实现比关系型数据库更快的过滤.特别是它对多条件的过滤支持非常好,比如年龄 ...

  5. ElasticSearch6.0 Java API 使用 排序,分组 ,创建索引,添加索引数据,打分等(一)

    ElasticSearch6.0  Java API  使用     排序,分组 ,创建索引,添加索引数据,打分等 如果此文章对你有帮助,请关注一下哦 1.1 搭建maven 工程  创建web工程 ...

  6. 为 Elasticsearch 添加中文分词,对比分词器效果

    转自:http://keenwon.com/1404.html 为 Elasticsearch 添加中文分词,对比分词器效果 Posted in 后端 By KeenWon On 2014年12月12 ...

  7. solr 添加索引

    添加索引模板: <add> <doc> <field name="employeeId">05991</field> <fie ...

  8. mysql 添加索引 mysql 创建索引

    1.添加PRIMARY KEY(主键索引) mysql>ALTER TABLE `table_name` ADD PRIMARY KEY ( `column` ) 2.添加UNIQUE(唯一索引 ...

  9. .添加索引和类型,同时设定edgengram分词和charsplit分词

    1.添加索引和类型,同时设定edgengram分词和charsplit分词 curl -XPUT 'http://127.0.0.1:9200/userindex/' -d '{   "se ...

随机推荐

  1. mac篇---使用iTerm2快捷连接SSH

    大家都知道使用iTerm2连接shh 使用命令 ssh -p22 root@129.10.10.1,然后输入密码即可. 但是每次都输入还是比较麻烦的.iTerm2为我们提供了快捷的方式.三步即可完成此 ...

  2. HBuilder生成证书

    一.安装jdk https://www.oracle.com/java/technologies/javase-downloads.html 二.打开CMD命令到JDK安装目录bin文件夹下 执行命令 ...

  3. SQLserver , MySQL的区别和各自的一些简单方法案列

    SQL Server数据库和MySQL数据库有什么区别呢?今天我们来分析一下这两种数据库的不同之处以及这两种数据库的一些简单用途:SQL Server数据库和MySQL数据库有什么区别: 对于程序开发 ...

  4. redis(九):Redis 哈希(Hash)(python)

    # -*- coding: utf-8 -*- import redis #这个redis不能用,请根据自己的需要修改 r =redis.Redis(host="123.56.74.190& ...

  5. tcpreplay的使用指导

    Tcpreplay的介绍 简单的说, tcpreplay是一种pcap包的重放工具, 它可以将用ethreal, wireshark工具抓下来的包原样或经过任意修改后重放回去. 它允许你对报文做任意的 ...

  6. Ant-Design-Vue中关于Form组件的使用

    1.创建form表单的两种方式,不同的方式在js中创建表单的方式也不同 方式1:一般使用在搜索表单中,只需要双向绑定数据即可,那就使用这种方法即可 <template> <a-for ...

  7. scss : div水平垂直居中

    scss 是一个很好用的css预处理语言,有很多很好的特性. 比如 mixin. 我们可以像使用函数那样使用mixin. 比如写一个div水平垂直居中. 上代码. @mixin absolute_ce ...

  8. C# 判断和创建目录路径

    在进行一些导出或下载时,需要创建一个本地路径,以供文件进行下载和创建. if (Directory.Exists(Server.MapPath("~/upimg/hufu")) = ...

  9. UVALive - 3644 X-Plosives (并查集)

    A secret service developed a new kind of explosive that attain its volatile property only when a spe ...

  10. 感知机算法(PLA)代码实现

    目录 1. 引言 2. 载入库和数据处理 3. 感知机的原始形式 4. 感知机的对偶形式 5. 多分类情况-one vs. rest 6. 多分类情况-one vs. one 7. sklearn实现 ...