Home | 简体中文 | 繁体中文 | 杂文 | Search | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 作品与服务 | Email

第 23 章 Elasticsearch

目录

23.1. 安装 Elasticsearch
23.1.1. RPM 安装
23.1.2. YUM 安装
23.1.3. 测试安装是否正常
23.2. 文档API
23.2.1. 快速上手
23.2.2. 写入 PUT/POST
23.2.3. 获取 GET
23.2.3.1. _source
23.2.4. 检查记录是否存在
23.2.5. 删除 Delete
23.2.6. 参数
23.2.6.1. pretty 格式化 json
23.3. 搜索
23.3.1. 分页
23.3.2. 字符串搜索
23.3.3. Query DSL
23.3.3.1. match
23.3.3.2. multi_match
23.3.3.3. sort
23.3.3.4. _source
23.4. Plugin 插件管理
23.4.1. 手工安装插件
23.4.2. plugin 命令
23.4.3. 插件测试
23.5. 映射
23.5.1. 查看 _mapping
23.5.2. 删除 _mapping
23.5.3. 创建 _mapping
23.5.4. 修改 _mapping
23.5.5. 数据类型
23.5.5.1. date
23.6. Alias management 别名管理
23.6.1. 查看索引别名
23.6.2. 创建索引别名
23.6.3. 修改别名
23.6.4. 删除别名
23.7. Example
23.7.1. 新闻资讯应用案例
23.8. FAQ
23.8.1. Plugin [analysis-ik] is incompatible with Elasticsearch [2.3.5]. Was designed for version [2.3.4]
23.8.2. mapper_parsing_exception: failed to parse [ctime]

http://www.elasticsearch.org/

23.1. 安装 Elasticsearch

23.1.1. RPM 安装

yum localinstall https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/rpm/elasticsearch/2.3.4/elasticsearch-2.3.4.rpm
			

23.1.2. YUM 安装

			
rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch

cat >> /etc/yum.repos.d/elasticsearch.repo <<EOF
[elasticsearch-2.x]
name=Elasticsearch repository for 2.x packages
baseurl=https://packages.elastic.co/elasticsearch/2.x/centos
gpgcheck=1
gpgkey=https://packages.elastic.co/GPG-KEY-elasticsearch
enabled=1
EOF

yum install elasticsearch

sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service
			
			

查看 RPM 包中所含文件

[root@localhost ~]# rpm -ql elasticsearch-2.3.4-1.noarch 
/etc/elasticsearch
/etc/elasticsearch/elasticsearch.yml
/etc/elasticsearch/logging.yml
/etc/elasticsearch/scripts
/etc/init.d/elasticsearch
/etc/sysconfig/elasticsearch
/usr/lib/sysctl.d
/usr/lib/sysctl.d/elasticsearch.conf
/usr/lib/systemd/system/elasticsearch.service
/usr/lib/tmpfiles.d
/usr/lib/tmpfiles.d/elasticsearch.conf
/usr/share/elasticsearch/LICENSE.txt
/usr/share/elasticsearch/NOTICE.txt
/usr/share/elasticsearch/README.textile
/usr/share/elasticsearch/bin
/usr/share/elasticsearch/bin/elasticsearch
/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec
/usr/share/elasticsearch/bin/elasticsearch.in.sh
/usr/share/elasticsearch/bin/plugin
/usr/share/elasticsearch/lib
/usr/share/elasticsearch/lib/HdrHistogram-2.1.6.jar
/usr/share/elasticsearch/lib/apache-log4j-extras-1.2.17.jar
/usr/share/elasticsearch/lib/commons-cli-1.3.1.jar
/usr/share/elasticsearch/lib/compiler-0.8.13.jar
/usr/share/elasticsearch/lib/compress-lzf-1.0.2.jar
/usr/share/elasticsearch/lib/elasticsearch-2.3.4.jar
/usr/share/elasticsearch/lib/guava-18.0.jar
/usr/share/elasticsearch/lib/hppc-0.7.1.jar
/usr/share/elasticsearch/lib/jackson-core-2.6.6.jar
/usr/share/elasticsearch/lib/jackson-dataformat-cbor-2.6.6.jar
/usr/share/elasticsearch/lib/jackson-dataformat-smile-2.6.6.jar
/usr/share/elasticsearch/lib/jackson-dataformat-yaml-2.6.6.jar
/usr/share/elasticsearch/lib/jna-4.1.0.jar
/usr/share/elasticsearch/lib/joda-convert-1.2.jar
/usr/share/elasticsearch/lib/joda-time-2.9.4.jar
/usr/share/elasticsearch/lib/jsr166e-1.1.0.jar
/usr/share/elasticsearch/lib/jts-1.13.jar
/usr/share/elasticsearch/lib/log4j-1.2.17.jar
/usr/share/elasticsearch/lib/lucene-analyzers-common-5.5.0.jar
/usr/share/elasticsearch/lib/lucene-backward-codecs-5.5.0.jar
/usr/share/elasticsearch/lib/lucene-core-5.5.0.jar
/usr/share/elasticsearch/lib/lucene-grouping-5.5.0.jar
/usr/share/elasticsearch/lib/lucene-highlighter-5.5.0.jar
/usr/share/elasticsearch/lib/lucene-join-5.5.0.jar
/usr/share/elasticsearch/lib/lucene-memory-5.5.0.jar
/usr/share/elasticsearch/lib/lucene-misc-5.5.0.jar
/usr/share/elasticsearch/lib/lucene-queries-5.5.0.jar
/usr/share/elasticsearch/lib/lucene-queryparser-5.5.0.jar
/usr/share/elasticsearch/lib/lucene-sandbox-5.5.0.jar
/usr/share/elasticsearch/lib/lucene-spatial-5.5.0.jar
/usr/share/elasticsearch/lib/lucene-spatial3d-5.5.0.jar
/usr/share/elasticsearch/lib/lucene-suggest-5.5.0.jar
/usr/share/elasticsearch/lib/netty-3.10.5.Final.jar
/usr/share/elasticsearch/lib/securesm-1.0.jar
/usr/share/elasticsearch/lib/snakeyaml-1.15.jar
/usr/share/elasticsearch/lib/spatial4j-0.5.jar
/usr/share/elasticsearch/lib/t-digest-3.0.jar
/usr/share/elasticsearch/modules
/usr/share/elasticsearch/modules/lang-expression
/usr/share/elasticsearch/modules/lang-expression/antlr4-runtime-4.5.1-1.jar
/usr/share/elasticsearch/modules/lang-expression/asm-5.0.4.jar
/usr/share/elasticsearch/modules/lang-expression/asm-commons-5.0.4.jar
/usr/share/elasticsearch/modules/lang-expression/lang-expression-2.3.4.jar
/usr/share/elasticsearch/modules/lang-expression/lucene-expressions-5.5.0.jar
/usr/share/elasticsearch/modules/lang-expression/plugin-descriptor.properties
/usr/share/elasticsearch/modules/lang-expression/plugin-security.policy
/usr/share/elasticsearch/modules/lang-groovy
/usr/share/elasticsearch/modules/lang-groovy/groovy-2.4.6-indy.jar
/usr/share/elasticsearch/modules/lang-groovy/lang-groovy-2.3.4.jar
/usr/share/elasticsearch/modules/lang-groovy/plugin-descriptor.properties
/usr/share/elasticsearch/modules/lang-groovy/plugin-security.policy
/usr/share/elasticsearch/modules/reindex
/usr/share/elasticsearch/modules/reindex/plugin-descriptor.properties
/usr/share/elasticsearch/modules/reindex/reindex-2.3.4.jar
/usr/share/elasticsearch/plugins
/var/lib/elasticsearch
/var/log/elasticsearch
/var/run/elasticsearch
			

23.1.3. 测试安装是否正常

启动

/etc/init.d/elasticsearch start			
			

链接测试

[root@localhost ~]# curl -X GET http://localhost:9200/
{
  "name" : "Jack of Hearts",
  "cluster_name" : "elasticsearch",
  "version" : {
    "number" : "2.3.4",
    "build_hash" : "e455fd0c13dceca8dbbdbb1665d068ae55dabe3f",
    "build_timestamp" : "2016-06-30T11:24:31Z",
    "build_snapshot" : false,
    "lucene_version" : "5.5.0"
  },
  "tagline" : "You Know, for Search"
}
			
comments powered by Disqus