参考教程

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. python django url直接访问txt文件。urls.py路由直接指向txt文件

    from django.views.generic import TemplateView urlpatterns = [ url(r'^test/',TemplateView.as_view(tem ...

  2. Jmockit 构造函数与初始代码块

    from Jmockit 中文网 http://jmockit.cn/showArticle.htm?channel=4&id=14 有些编写不良好的类的构造函数,初始代码块,静态代码块存在大 ...

  3. 后端必备的 Git 分支开发规范指南 转

    原文链接 作者:稻草叔叔 http://juejin.im/post/5b4328bbf265da0fa21a6820 点击上方 "后端技术精选",选择 "置顶公众号&q ...

  4. mysql-5.7.23-winx64 解压版详细安装教程

    1.下载解压版: 2.配置环境变量 (1)新建MYSQL_HOME变量,并配置值为: C:\softwaretool\mysql-5.7.23-winx64 计算机→属性→高级系统设置→高级→环境变量 ...

  5. 【MySQL】条件查询之排序聚合分组分页查询

    排序查询 语法:order by 子句 order by 排序字段1 排序方式1 , 排序字段2 排序方式2... 排序方式: ASC:升序,默认的. DESC:降序. 注意: 如果有多个排序条件,则 ...

  6. SAP-简单的OALV演示练习

    接上一篇传统ALV:https://www.cnblogs.com/BruceKing/p/11320165.html. 首先介绍下什么是ALV,在R/3 4.6C之前ALV全称为ABAP List ...

  7. 【设计模式】Bridge

    前言 Bridge设计模式,将一个复杂类分成可以单独开发的部分.分成的两个部分,abstraction,implementation.字面上是抽象和实现,但不同于抽象方法及其实现.下面摘录Wiki的两 ...

  8. E203 译码模块(2)

    常用的alu算术运算指令(包括ecall和 ebreak)在regular alu单元处理.regular alu单元为alu单元的一个子单元.regular单元的信息总线共21位,格式如下图所示,其 ...

  9. rhel安装输入法

    # yum install "@Chinese Support" 安装完成后,设置输入法: System -> Preferences -> Input Method

  10. pip python

    简介 pip 是一个安装和管理 Python 包的工具,python安装包的工具有easy_install, setuptools, pip,distribute.使用这些工具都能下载并安装djang ...