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. sql语句-CASE WHEN用法详解

    当我们需要从数据源上 直接判断数据显示代表的含义的时候 ,就可以在SQL语句中使用 Case When这个函数了. Case具有两种格式.简单Case函数和Case搜索函数. 第一种 格式 : 简单C ...

  2. Activity启动流程分析

    我们来看一下 startActivity 过程的具体流程.在手机桌面应用中点击某一个 icon 之后,实际上最终就是通过 startActivity 去打开某一个 Activity 页面.我们知道 A ...

  3. appium升级操作

    在app自动化测试中经常会碰到,因为appium版本低而导致,appium客户端连接不到appium服务端等一系列错误~ 其实appium升级很简单的哦~ 打开cmd命令行终端,键入npm updat ...

  4. .Net Core微服务入门全纪录(八)——Docker Compose与容器网络

    Tips:本篇已加入系列文章阅读目录,可点击查看更多相关文章. 前言 上一篇[.Net Core微服务入门全纪录(七)--IdentityServer4-授权认证]中使用IdentityServer4 ...

  5. SpringCloud组件的停更和替换说明

    SpringCloud的Hoxton版本,和之前的版本相比,用新的组件替换掉了原来大部分的组件,老的组件现在处于 停更不停用 的状况. 详情见下图(× 的表示之前的组件,现在停更了的:√ 的表示新的替 ...

  6. Pop!_OS下安装C++编程工具

    Pop!_OS下C++编程 #0x0 Visual Studio Code #0x1 C++ 0x11 code::blocks #0x0 Visual Studio Code 下载安装vscode ...

  7. 数据可视化之powerBI基础(十六)PowerQuery的这个小功能,让你轻松发现数据质量问题

    https://zhuanlan.zhihu.com/p/64418072 源数据常常包含各种差错值,为了进行下一步的分析,我们必须先找出并更正这些差错,做这些工作几乎不会有什么快乐感可言,但却往往需 ...

  8. pointer-events:none 的应用

    相信很多人都遇到过 Retina屏的1px边框  的问题. 很多人都用 :before,:after 伪类 eg: .div:after { position: absolute; top: 0;   ...

  9. Sequential Minimal Optimization: A Fast Algorithm for Training Support Vector Machines 论文研读

    摘要 本文提出了一种用于训练支持向量机的新算法:序列最小优化算法(SMO).训练支持向量机需要解决非常大的二 次规划(QP)优化问题.SMO 将这个大的 QP 问题分解为一系列最小的 QP 问题.这些 ...

  10. ElementUI中 el-table-column 显示的数据为多个返回数据的拼接

    遇到个问题就是其中有个要展示的数据来自接口返回的两个字段. 原用法是: 原以为prop=" "中只能放一个字段的数据,想放两个字段数据的话,要把 <el-table-colu ...