ElasticSearch相关基础汇总
ElasticSearch相关基础汇总: 1、版本演变: 1.x----->2.x----->5.x----->6.x 2、mac电脑上安装elasticsearch命令: brew install elasticsearch 或者直接下载压缩包解压 3、mac上查看已经安装好的services列表: brew services list 4、实用插件head的安装: (1)、下载:git clone git://github.com/mobz/elasticsearch-head.git (2)、cd elasticsearch-head (3)、npm install 或者 cnpm install (4)、npm run start 或者 cnpm run start 5、配置elasticsaerch 和 elasticsearch-head 插件 (1)、停掉elasticsearch-head (2)、停掉elasticsearch: brew services stop elasticsearch (3)、查找elasticsearch.yml文件位置: sudo find / -name elasticsearch.yml (4)、在elasticsearch.yml文件末尾添加: http.cors.enabled: true http.cors.allow-origin: "*" (5)、 启动es: brew services start elasticsearch 启动elasticsearch-head: cnpm run start 6、分布式安装es ,一个master节点,两个slave节点 (1)、修改主节点elasticsearch.yml配置文件,在文件末尾添加: cluster.name: biges #指定es集群的名字 node.name: master #指定节点的名字 node.master: true #指定当前节点就是主节点 network.host: 127.0.0.1 #指定为本机地址,端口还是9200 (2)、修改slave节点的 elasticsearch.yml 文件: cluster.name: biges #指定es集群的名字 node.name: slave1/slave2 #指定节点的名字 network.host: 127.0.0.1 #指定为本机地址 http.port: 9201/9202 #指定slave节点的端口 discovery.zen.ping.unicast.hosts: ["127.0.0.1"] #发现master位置 7、es基础概念 (1)、集群与节点: master + slave1 + slave2 总体是一个集群,master、slave1、slave2分别是一个子节点 (2)、索引:含有相同属性的文档的集合 (3)、类型:索引可以定义一个或者多个类型,文档必须属于一个类型 (4)、文档:文档是可以被索引的基本数据单位 (5)、分片:每个索引都有多个分片,每个分片是一个lucene索引 (6)、备份:拷贝一份分片就完成了分片的备份 8.es中索引相关: (1)、API基本格式: http://<ip>:<port>/<索引>/<类型>/<文档id> (2)、restful api 的 http 动词: get/put/post/delete (3)、实用postman创建索引很方便。 9.es的查询语法 (1)、简单查询: 127.0.0.1:9200/book/novel/1 (2)、条件查询 127.0.0.1:9200/book/_search { "query":{ #"match_all": {} "match":{ "title": "elastcisearch" } }, "from": 1, "size": 10, "sort": [ {"publish_date": {"order": "desc"}} ] } (3)、聚合查询 127.0.0.1:9200/book/_search { "aggs":{ "group_by_word_count": { "terms": { "field": "word_count" } }, "group_by_publish_date": { "terms": { "field": "publish_date" } } } } 或者 { "aggs":{ "group_word_count": { "stats": { "field": "word_count" } } } } 10、高级查询 子条件查询: 特定字段查询所指特定值 复合条件查询: 以一定的逻辑组合子条件查询 (1)、Query 全文本查询: 针对文本类型数据 字段级别查询: 针对结构化数据,如数字、日期等 模糊匹配: 127.0.0.1:9200/book/_search { "query": { "match": { "author"; "test" } } } 或者 { "query": { "match_phrase": { "title"; "elasticsearch入门" } } } 多字段匹配查询: { "query":{ "multi_match": { "query": "瓦利", "fields": ["author" ,"title"] } } } 语法查询: { "query": { "query_string": { #"query": "(elasticsearch AND 大法) OR python" "query": "test OR elasticsearch", "fields": ["title","author"] } } } 结构化查询: { "query":{ "term":{ #"word_count": 1000 "author": "test" } } } 范围查询: { "query": { "range": { "word_count": { "gte": 1000, "lte": 10000 } } } } (2)、filter 在查询的过程中,只判断该文档是否满足条件,只有yes或者no 127.0.0.1:9200/book/_search { "query": { "bool": { "filter": { "term": { "word_count": 1000 } } } } } (3)、复合查询 固定分数查询 , 只支持filter 127.0.0.1:9200/_search { "query": { "constant_score": { "filter": { "match": { "title": "elasticsearch" } }, "boost": 2 } } } 布尔查询 { "query": { "bool": { "should": [ { "match": { "author": "test" } }, { "match": { "title": "elasticsearch" } } ] } } } 或者: { "query": { "bool": { "must": [ { "match": { "author": "test" } }, { "match": { "title": "elasticsearch" } } ], "filter":[ { "term": { "word_count": 1000 } } ] } } } 或 { "query": { "bool": { "must_not": { "term": { "author": "test" } } } } } 备注:本文是从个人的印象笔记之中整理到博客文章的,印象笔记写博客,整理文章还是欠缺,还得是博客才行,后期会保持每天一篇的节奏将个人印象笔记中记录的东西整理到阿里云博客上,阿里云博客上传图片有时候会显示不出来,尴尬。
低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
Apache Carbondata on Preto
1.download apache carbondata - 1.5.3apache carbondata - 1.5.4apache spark - 2.3.2apache hadoop - 2.7.2presto server - 0.210presto client - 0.210 2.Configurations mkdir -p etc/catalog -- in presto servertouch carbondata.properties -- in presto server /conf a).vi config.properties ######## Coordinator Configurations ########## # #coordinator=true #node-scheduler.include-coordinator=false #http-server.http.port=8086 #query.max-memory=5GB #query.max-total-memory-per-node=5GB #query.max-memory-per-no...
- 下一篇
世界博览:“谷歌”地球共和国?,互联网营销
核心提示:我们以谢尔盖·布林的一段话来展望Google 与互联网时代的未来。他说:“当我还是个小孩子的时候,想学点什么东西,要跑很远去当地的图书馆,如果运气好,才能找到一本感兴趣的书。在不久的将来,人们可以在数秒之内协作完成专业研究。当今世界经济还是乌云笼罩,对我们所有人来说都是一段相当困难的时期。但等到今天的孩子们长大时,这次衰退只不过是历史上的一个脚印,而我们一直以来所创造的技术将决定未来。” 刚刚过去的情人节那天,生活在硅谷的华裔软件工程师赵先生邀请妻子来到屋后的花园里,他一手牵着她的手,另一只手中握着手机。夜空中挂满窃窃私语的星斗,赵先生对准星空拍了几张照片,只见手机屏幕上显示出相应的星座名称。 “我太太当时吃惊得说不出话来!”人们虽然已经习惯了手机应用越来越智能化,但很少有人想象得到——Google的一项创新性应用能使手机拥有一只具有识别信息能力的“魔眼”。 2009年12月7日,Google公司发布了手机搜索应用“Google Goggles”,即“视觉搜索”,用户使用Android操作系统的手机拍摄照片即可搜索相关信息,这让搜索引擎向真正的智能化迈上了一个新台阶。 现在G...
相关文章
文章评论
共有0条评论来说两句吧...
文章二维码
点击排行
推荐阅读
最新文章
- Jdk安装(Linux,MacOS,Windows),包含三大操作系统的最全安装
- SpringBoot2更换Tomcat为Jetty,小型站点的福音
- CentOS8安装Docker,最新的服务器搭配容器使用
- SpringBoot2整合MyBatis,连接MySql数据库做增删改查操作
- CentOS8,CentOS7,CentOS6编译安装Redis5.0.7
- 设置Eclipse缩进为4个空格,增强代码规范
- Docker使用Oracle官方镜像安装(12C,18C,19C)
- CentOS8编译安装MySQL8.0.19
- SpringBoot2整合Redis,开启缓存,提高访问速度
- SpringBoot2配置默认Tomcat设置,开启更多高级功能