参考教程

elasticsearch入门教程:https://www.yiibai.com/elasticsearch/elasticsearch-getting-start.html

Java JDK安装和配置:https://www.yiibai.com/java/java_environment_setup.html

网上的elasticsearch和jdk安装包下载速度太慢了,这是我下载下来保存的

=======================================================

elasticsearch windows安装包:链接: https://pan.baidu.com/s/1fE6rE-lGuwJuA29_0C_VXw 提取码: 5v2v

Java JDK windows64位安装包:链接: https://pan.baidu.com/s/1NVuARW_cK6WeNy-VhTEiVQ 提取码: 8jxs

curl  windows安装包:链接: https://pan.baidu.com/s/1RLOQOWEo2vt_8YkK7fI-ZQ 提取码: wpny

=======================================================

Elasticsearch需要先安装JDK并配置环境变量,之后下载安装Elasticsearch

启动 ElasticSearch

E:\elasticsearch-7.5.-windows-x86_64\elasticsearch-7.5.\bin>elasticsearch.bat

启动成功

启动成功后浏览器地址栏输入:http://localhost:9200/

创建索引

curl -H "Content-Type: application/json" -XPUT "http://localhost:9200/movies/movie/1" -d "{\"title\": \"The Godfather\",\"director\":\"Francis Ford Coppola\",\"year\": 1972}"
{"_index":"movies","_type":"movie","_id":"","_version":,"result":"updated","_shards":{"total":,"successful":,"failed":},"_seq_no":,"_primary_term":}

注意,{}内的双引号记得加反斜杠\转义

由ID获取文档/索引

curl  -H "Content-Type: application/json" -XGET "http://localhost:9200/movies/movie/1" -d''
{"_index":"movies","_type":"movie","_id":"","_version":,"_seq_no":,"_primary_term":,"found":true,"_source":{"title": "The Godfather","director":"Francis Ford Coppola","year": }}

删除文档

curl  -H "Content-Type: application/json" -XGET "http://localhost:9200/movies/movie/1" -d''
{"_index":"movies","_type":"movie","_id":"","found":false}

搜索所有索引和类型 _search

curl -H "Content-Type: application/json"  -XGET "http://localhost:9200/_search"
{"took":,"timed_out":false,"_shards":{"total":,"successful":,"skipped":,"failed":},"hits":{"total":{"value":,"relation":"eq"},"max_score":1.0,"hits":[{"_index":"movies","_type":"movie","_id":"","_score":1.0,"_source":{"title": "gangtie","director": "pfeiliu","year": ,"genres": ["nishishui", "asdwqe"]}},{"_index":"movies","_type":"movie","_id":"","_score":1.0,"_source":{"title": "The Godfather","director": "Francis Ford Coppola","year": ,"genres": ["Crime", "Drama"]}},{"_index":"movies","_type":"movie","_id":"","_score":1.0,"_source":{"title": "lawer","director": "lean","year": ,"genres": ["youar", "pl"]}}]}}

搜索某索引的数据类型

curl -H "Content-Type: application/json"  -XGET "http://localhost:9200/movies/_search"
{"took":,"timed_out":false,"_shards":{"total":,"successful":,"skipped":,"failed":},"hits":{"total":{"value":,"relation":"eq"},"max_score":1.0,"hits":[{"_index":"movies","_type":"movie","_id":"","_score":1.0,"_source":{"title": "gangtie","director": "pfeiliu","year": ,"genres": ["nishishui", "asdwqe"]}},{"_index":"movies","_type":"movie","_id":"","_score":1.0,"_source":{"title": "The Godfather","director": "Francis Ford Coppola","year": ,"genres": ["Crime", "Drama"]}},{"_index":"movies","_type":"movie","_id":"","_score":1.0,"_source":{"title": "lawer","director": "lean","year": ,"genres": ["youar", "pl"]}}]}}

在指定索引中显式搜索指定类型的文档

curl -H "Content-Type: application/json"  -XGET "http://localhost:9200/movies/movie/_search"
{"took":,"timed_out":false,"_shards":{"total":,"successful":,"skipped":,"failed":},"hits":{"total":{"value":,"relation":"eq"},"max_score":1.0,"hits":[{"_index":"movies","_type":"movie","_id":"","_score":1.0,"_source":{"title": "gangtie","director": "pfeiliu","year": ,"genres": ["nishishui", "asdwqe"]}},{"_index":"movies","_type":"movie","_id":"","_score":1.0,"_source":{"title": "The Godfather","director": "Francis Ford Coppola","year": ,"genres": ["Crime", "Drama"]}},{"_index":"movies","_type":"movie","_id":"","_score":1.0,"_source":{"title": "lawer","director": "lean","year": ,"genres": ["youar", "pl"]}}]}}

常见错误处理:

错误:{"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406}

解决:添加:-H "Content-Type: application/json"

错误:{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"failed to parse"}],"type":"mapper_parsing_exception","reason":"failed to parse","caused_by":{"type":"json_e_o_f_exception","reason":"Unexpected end-of-input in field name\n at [Source: org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@3c1b21d; line: 1, column: 133]"}},"status":400}curl: (3) unmatched close brace/bracket in URL position 5:
1972}

解决:在{}内的双引号都加上一个"\"转义

查看集群健康状况:

浏览器输入:http://localhost:9200/_cat

或者http://localhost:9200/_cat/health?v

查看所有索引:

http://localhost:9200/_cat/indices?v

elasticsearch入门及安装的更多相关文章

  1. 《读书报告 -- Elasticsearch入门 》-- 安装以及简单使用(1)

    <读书报告 – Elasticsearch入门 > 第一章 Elasticsearch入门 Elasticsearch是一个实时的分布式搜索和分析引擎,使得人们可以在一定规模上和一定速度上 ...

  2. 全文搜索引擎Elasticsearch入门实践

    全文搜索引擎Elasticsearch入门实践 感谢阮一峰的网络日志全文搜索引擎 Elasticsearch 入门教程 安装 首先需要依赖Java环境.Elasticsearch官网https://w ...

  3. ElasticSearch入门 第一篇:Windows下安装ElasticSearch

    这是ElasticSearch 2.4 版本系列的第一篇: ElasticSearch入门 第一篇:Windows下安装ElasticSearch ElasticSearch入门 第二篇:集群配置 E ...

  4. ElasticSearch入门 :Windows下安装ElasticSearch

    这是ElasticSearch 2.4 版本系列的第一篇: ElasticSearch入门 第一篇:Windows下安装ElasticSearch ElasticSearch入门 第二篇:集群配置 E ...

  5. elasticsearch入门使用(四) 索引、安装IK分词器及增删改查数据

    一.查看.创建索引 创建一个名字为user索引: curl -X PUT 'localhost:9200/stu' {"acknowledged":true,"shard ...

  6. Elasticsearch入门教程(一):Elasticsearch及插件安装

    原文:Elasticsearch入门教程(一):Elasticsearch及插件安装 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:h ...

  7. Centos 7安装和配置 ElasticSearch入门小白

    实验环境: 操作系统:Centos 7.5 服务器ip:192.168.1.198 运行用户:root 网络环境:Internet 在企业生产环境有很多服务器的时候.很多业务模块的日志的时候运维人员需 ...

  8. ElasticSearch入门-基本概念介绍以及安装

    Elasticsearch基本概念 Elasticsearch是基于Lucene的全文检索库,本质也是存储数据,很多概念与传统关系型数据库类似. 传统关系型数据库与Elasticsearch进行概念对 ...

  9. ElasticSearch入门知识扫盲

    ElasticSearch 入门介绍 tags: 第三方 lucene [toc] 1. what Elastic Search(ES)是什么 全文检索和lucene 全文检索 优点:高效,准确,分词 ...

随机推荐

  1. fiddler 抓取winform wcf包

    修改客户端配置 <system.net> <defaultProxy> <proxy bypassonlocal="false" usesystemd ...

  2. Java中的Object类的几个方法

    Object类被称为上帝类,也被称为祖宗类.在定义Java类时,如果没有指定父类,那么默认都会去继承Object类.配合Java的向上类型转换,借助Object类就可以完成很多工作了. 在Object ...

  3. 快速缓存刷新CDN节点的方法

    缓存刷新方式有 URL 刷新.目录刷新和 URL 预热.URL 刷新是以文件为单位进行缓存刷新.目录刷新是以目录为单位,将目录下的所有文件进行缓存刷新.URL 预热是以文件为单位进行资源预热. 刷新后 ...

  4. Java代理类Proxy的用法

    代理(proxy) 利用代理可以在运行时创建一个实现了一组给定接口的新类.这种功能只有在编译时无法确定需要实现哪个接口时才有必要使用. 何时使用代理 假设有一个表示接口的Class对象(有可能只包含一 ...

  5. LINQ 之 LookUp

    声明:本文为www.cnc6.cn原创,转载时请注明出处,谢谢! 本文作者文采欠佳,文字表达等方面不是很好,但实际的代码例子是非常实用的,请作参考. 一.先准备要使用的类: 1.Person类: cl ...

  6. 用guava快速打造两级缓存能力

    首先,咱们都有一共识,即可以使用缓存来提升系统的访问速度! 现如今,分布式缓存这么强大,所以,大部分时候,我们可能都不会去关注本地缓存了! 而在一起高并发的场景,如果我们一味使用nosql式的缓存,如 ...

  7. 记录微信支付开发中的小经验(errcode = 40163; errmsg = "code been used")

    今天上午客户提出问题,看了一下报错截图,应该是我更新版本时少传了一个参数,导致后续报错, 心里想着小问题,直接生产环境添加一下就行了,于是就为了我这一上午的悲剧埋下了伏笔 十分自信的把页面中的代码添加 ...

  8. NET 特性(Attribute)

    NET 特性(Attribute) 转自 博客园(Fish) 特性(Attribute):是用于在运行时传递程序中各种元素(比如类.方法.结构.枚举.组件等)的行为信息的声明性标签. 您可以通过使用特 ...

  9. jsonp格式前端发送和后台接受写法

    jsonp是ajax提交的一种格式不会受跨域限制 一.前端发送 <button>11111</button> <script src="https://cdn. ...

  10. head中的base标签:设置超链接的默认行为

    默认情况下,如果不指定超链接的target属性,则在当前窗口打开.使用head中的base可以制定超链接的base类,一切超链接都会继承它的属性. <html> <head> ...