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. vs dll lib 使用记录

    今天把学习opengl的项目从一个电脑copy到另一个电脑时候,发生了glu.dll找不到,导致项目起不来的问题.后来网上查找发现, 虽然我使用了静态连接 mt/mtd 编译, 但是有可能lib中并没 ...

  2. Windows 用来定位 DLL 的搜索路径

    参考自:https://msdn.microsoft.com/zh-cn/library/253b8k2c.aspx 通过隐式和显式链接,Windows 首先搜索“已知 DLL”,如 Kernel32 ...

  3. STL测试3)优先级队列实现二叉堆

    用法: big_heap.empty();判断堆是否为空 big_heap.pop();弹出栈顶元素最大值 big_heap.push(x);将x添加到最大堆 big_heap.top();返回栈顶元 ...

  4. scrapy (三) : 请求传参

    scrapy 请求传参 1.定义数据结构item.py文件 ''' field: item.py ''' # -*- coding: utf-8 -*- # Define here the model ...

  5. 数据可视化之powerBI基础(十四)Power BI中创建联动切片器

    https://zhuanlan.zhihu.com/p/67564062 进行数据分析时,每个分析维度并不总是独立的,比如省份是一个维度,城市也是一个维度,而这两个维度之间是有逻辑关系的,那么在进行 ...

  6. scrapy 源码解析 (三):启动流程源码分析(三) ExecutionEngine执行引擎

    ExecutionEngine执行引擎 上一篇分析了CrawlerProcess和Crawler对象的建立过程,在最终调用CrawlerProcess.start()之前,会首先建立Execution ...

  7. Python之爬虫(十六) Scrapy框架中选择器的用法

    Scrapy提取数据有自己的一套机制,被称作选择器(selectors),通过特定的Xpath或者CSS表达式来选择HTML文件的某个部分Xpath是专门在XML文件中选择节点的语言,也可以用在HTM ...

  8. ValueError: X needs to contain only non-negative integers.

    for feature in short_cate_feature: enc.fit(data[feature].values.reshape(-1, 1)) base_train_csr = spa ...

  9. 使用Java带你打造一款简单的英语学习系统

    [一.项目背景] 随着移动互联网的发展,英语学习系统能结构化的组织海量资料.针对用户个性需求,有的放矢地呈现给用户,从而为英语学习者提供便利,提升他们的学习效率. [二.项目目标] 1. 实现美观的界 ...

  10. python也能玩视频剪辑!moviepy操作记录总结

    前几篇文章咱们介绍了一下图片的处理方式,今天咱们说说视频的处理.python能够支持视频的处理么?当然是肯定的,人生苦读,我用python.万物皆可python. moviepy库安装 今天咱们需要使 ...