ElasticSearch java 使用指南

ElasticSearch java  使用指南

一、ES 支持数据类型 与 DB的对比

Elasticsearch支持以下数据类型:
		文本: text keyword 
		数字: byte, short, integer, long
		浮点数: float, double
		布尔值: boolean
		Date: date
		
ES与 关 系型数据库对比:
	Database    table     row          column
	Index       type      document     field

二、ES 在Linux系统中 发送HTTP请求,请求头不匹配的错误:

{"error":"Content-Type header [application/x-www-form-urlencoded] is not supported"

       解决方案:

curl -H "Content-Type: application/json"   
curl : linux 系统中发送网络请求
-H   : 指定请求的方式 

      案例:

使用elasticsearch 添加数据到es中
curl -XPOST 192.168.14.173:32000/test_index_1221/test_type/5 -d '{'user_name':"xiaoming"}'
    {"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}
	   
修改之后,指定 header 头
    curl -H "Content-Type: application/json" -XPOST 192.168.14.173:32000/test_index_1221/test_type/5 -d '{'user_name':"xiaoming"}'

参考:https://blog.csdn.net/dtiove/article/details/78870607

三、 在elasticsearch6.0之后,对es中 数据类型做了调整

数据类型String设置为过时。使用 text和keyword 作为文本的数据类型;
text和keyword的区别:
    keyword : 存储数据的时候,不会分词建立索引
    text :存储数据的时候,会自动分词,并生成索引。这是很智能的,但在有些字段里面是没用的,所以对于有些字段使用text则浪费了空间)。

参考:elasticsearch的keyword与text的区别

四、elasticsearch 创建索引与映射结构

参考:Elasticsearch创建索引和映射结构详解

         ElasticSearch 6.2 Mapping参数说明及text类型字段聚合查询配置

五、elasticsearch -Mapping 映射结构

★★★  索引建立之后,修改字段的类型
思路:ES在建立索引之后,不支持修改索引的字段类型。如果想要修改字段的类型,只能重新建立新的索引、及映射结构;
     把以前的数据导入到新的索引结构中去,完成改变映射结构的母的;
步骤:
1.给已有的索引定一个别名,并指向该别名
2.新建一个新的索引,新的映射结构
3.把数据导入到新建的索引中 
4.将别名指向新的索引,取消旧的索引与别名之间的关联

参考:Elasticsearch实战系列-mapping 设置  

        ★★★已过期 ;  介绍了 stirng 类型的 index analyzer 的使用 ;

        ★★★ 索引建立之后,修改字段的类型

        ElasticSearch实战索引的Mapping映射那些事

        Elasticsearch 的坑爹事——记录一次mapping field修改过程

六、使用 curl 来操作 ElasticSearch 

Elasticsearch创建索引和映射结构详解:
		使用curl  新建索引
				  Mapping : 扁平结构
					    非扁平结构:树形结构
						       对象
						       嵌套对象

参考:https://www.cnblogs.com/sheeva/p/4837881.html

      ES 提供了REST风格的API可以很方便的实现对es的操作

 在Linux 中,使用 url来操作es :
	 curl -Xxxx http://xxx.xxx.xxx.xxx:9200/...

参考:https://www.cnblogs.com/zlslch/p/6474424.html

          https://blog.csdn.net/napoay/article/details/52012249

           ★★★ es 博客

七、ElasticSearch 个人理解:

       https://blog.csdn.net/it_lihongmin/article/details/71055553




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值