- 使用elasticsearch-head插件
- 使用elasticsearch提供的Restful接口直接访问
- 使用elasticsearch提供的API进行访问
- Talend API tester安装:

文章插图
- Postman安装:

文章插图
4.2使用Talend API tester进行es客户端操作 。1)Elasticsearch的接口语法
curl ‐X \'://:/?\' ‐d \'\' 其中:
文章插图
2)创建索引库index并添加映射mapping------PUT
PUT 请求体:article:type类型;相当于这个索引库中有张表叫做article下面定义的这张表中的字段的定义,
字段默认为不索引的;
analyzer:分词器使用标准分词器
{"mappings": {"article": {"properties": {"id": {"type": "long","store": true,"index": "not_analyzed"},"title": {"type": "text","store": true,"index": "analyzed","analyzer": "standard"},"content": {"type": "text","store": true,"index": "analyzed","analyzer": "standard"}}}}}
文章插图
在可视化工具elasticsearch-head中查看:

文章插图
3)先创建索引index,再添加mapping ----PUT我们可以在创建索引时设置mapping信息,当然也可以先创建索引然后再设置mapping 。在上一个步骤中不设置maping信息,直接使用put方法创建一个索引,然后设置mapping信息 。请求的url:
PUThttp://127.0.0.1:9200/hello2/article/_mapping请求体:{"article": {"properties": {"id": {"type": "long","store": true,"index": "not_analyzed"},"title": {"type": "text","store": true,"index": "analyzed","analyzer": "standard"},"content": {"type": "text","store": true,"index": "analyzed","analyzer": "standard"}}}}
文章插图
4)删除索引index ----DELETE请求URL:
DELETEhttp://127.0.0.1:9200/hello2
文章插图
5)创建文档document(向索引库中添加内容)---POST请求URL:
POSThttp://127.0.0.1:9200/hello/article/1请求体:{"id": 1,"title": "ElasticSearch是一个基于Lucene的搜索服务器","content": "它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口 。Elasticsearch是用Java开发的,并作为Apache许可条款下的开放源码发布,是当前流行的企业级搜索引擎 。设计用于云计算中,能够达到实时搜索,稳定,可靠,快速,安装使用方便 。"}
文章插图
在elasticsearch-head中查看:

文章插图
注意,一般我们将_id与id赋相同值 。
6)修改document内容----POST请求URL:
POST http://127.0.0.1:9200/hello/article/1
文章插图
在elasticsearch-head中查看:

文章插图
- 五一一件有趣的事作文400字 五一的作文400字左右
- 如何磨刀视频教程 怎么磨刀教程
- 我的开学第一课作文 我的开学第一课
- 英语作文myhobby怎么写
- 极品gre红宝书是什么 gre红宝书是什么
- 2020年gre考试取消怎么退款
- 反恐精英cs1.6电脑下载教程 反恐精英cs1.6
- 读书的快乐演讲稿600字作文 读书的快乐演讲稿怎么写
- 化妆步骤的先后顺序「新手学化妆详细教程」
- 高中英语作文模板 英语作文模板
特别声明:本站内容均来自网友提供或互联网,仅供参考,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
