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. kubernetes系列(十四) - 存储之PersistentVolume

    1. PersistentVolume(PV)简介 1.1 为什么需要Persistent Volume(PV) 1.2 PersistentVolume(PV)和Volume的区别 1.3 PV和P ...

  2. scala 数据结构(五):队列 Queue

    1 队列 Queue-基本介绍 队列的说明 1)队列是一个有序列表,在底层可以用数组或是链表来实现. 2)其输入和输出要遵循先入先出的原则.即:先存入队列的数据,要先取出.后存入的要后取出 3)在Sc ...

  3. python 面向对象专题(四):封装、多态、鸭子类型、类的约束、super

    https://www.cnblogs.com/liubing8/p/11321099.html 目录 Python面向对象04 /封装.多态.鸭子类型.类的约束.super 1. 封装 2. 多态 ...

  4. HotSpot VM运行时

    HotSpot VM运行时系统为HotSpot JIT编译器和垃圾收集器提供服务和通用API,同时还为VM提供启动.线程管理.JNI(Java本地接口)等基本功能.HotSpot VM运行时环境担当许 ...

  5. bzoj3155Preprefix sum

    bzoj3155Preprefix sum 题意: 询问一个数组前缀和数组的前缀和,支持单点修改. 题解: SSi=sigma(i,1,n)(n-i+1)*ai=(n+1)*Si-sigma(i,1, ...

  6. .Net Core 读取文件中文乱码

    首先,要知道.Net Core和.Net Framework两个环境下很多东西是不同的,接下来要说的这个就是其中一个. Encoding.Default,在  .NET Framework 中,Def ...

  7. Python Ethical Hacking - VULNERABILITY SCANNER(3)

    Polish the Python code using sending requests in a session Class Scanner. #!/usr/bin/env python impo ...

  8. 题解 CF1359A 【Berland Poker】

    题意 给出 \(n,m,k\) ,表示 \(k\) 名玩家打牌,共 \(n\) 张牌,\(m\) 张王,保证 \(k|n\) ,记得分为 拿到最多王的玩家手中王数 \(-\)拿到第二多王的玩家手中的王 ...

  9. ssh配置、vscode使用及常用扩展

    1.ssh配置 1.1 进入命令行 win + r  > cmd 1.2 输入如下代码直接回车即可生成ssh  ssh-keygen -t rsa -C "xxx@qq.com&quo ...

  10. justoj connect(边的处理)

    CONNECT https://oj.ismdeep.com/contest/problem?id=1702&pid=2 Problem Description 有nn个顶点,每个顶点有自己的 ...