一. 安装插件

  1. Marvel集群管理

    root@lj-ThinkPad-L460:~# sudo bin/plugin install license
    root@lj-ThinkPad-L460:~# sudo bin/plugin install marvel-agent 访问 http://localhost:9200/_plugin/marvel/
  2. Kibana 4.5.1可视化

    root@lj-ThinkPad-L460:~# wget https://download.elastic.co/kibana/kibana/kibana-4.5.1-linux-x64.tar.gz
    root@lj-ThinkPad-L460:~# vim config/kibana.yml
    Set the elasticsearch.url
    root@lj-ThinkPad-L460:~# ./bin/kibana 运行 访问 http://yourhost.com:5601
  3. 启动es

    ./elasticsearch --cluster.name my_cluster_name --node.name my_node_name

二.快速入门

  1. 管理

    #1.cluster healthy
    curl 'localhost:9200/_cat/health?v'
    #2. nodes in our cluster
    curl 'localhost:9200/_cat/nodes?v'
    #3.list all indices
    curl 'localhost:9200/_cat/indices?v'
  2. customer例子

    #1. create an index named "customer" and then list all the indexes again:
    ➜ ~ curl 'localhost:9200/_cat/indices?v'
    ➜ ~ curl 'localhost:9200/_cat/indices?v' #2. Let’s index a simple customer document into the customer index, "external" type, with an ID of 1
    ➜ ~ curl -XPUT 'localhost:9200/customer/external/1?pretty' -d '
    {
    "name": "John Doe"
    }' # ip:port/index name/type/id
    ➜ ~ curl -XGET 'localhost:9200/customer/external/1?pretty'
    {
    "_index" : "customer",
    "_type" : "external",
    "_id" : "1",
    "_version" : 1,
    "found" : true,
    "_source" : {
    "name" : "John Doe" # full json
    }
    } #3. delete the index that we just created
    # curl -X<REST Verb> <Node>:<Port>/<Index>/<Type>/<ID>
    ➜ ~ curl -XGET 'localhost:9200/customer/external/1?pretty' #4. batch processing
    ➜ ~ curl -XPOST 'localhost:9200/customer/external/_bulk?pretty' -d '
    {"index":{"_id":"1"}}
    {"name": "John ss" }
    {"index":{"_id":"2"}}
    {"name": "Jane Doe" }
    '
  3. bank例子

    #1. download json file : https://github.com/bly2k/files/blob/mas
    #2. load file
    ➜ ~ curl -XPOST 'localhost:9200/bank/account/_bulk?pretty' --data-binary "@accounts.json"
    ➜ ~ curl 'localhost:9200/_cat/indices?v'
    health status index pri rep docs.count docs.deleted store.size pri.store.size
    yellow open bank 5 1 1000 0 442.1kb 442.1kb
    yellow open .marvel-es-1-2016.06.14 1 1 4816 26 1.9mb 1.9mb
    yellow open .marvel-es-data-1 1 1 4 2 12.2kb 12.2kb
    yellow open .kibana 1 1 1 0 3.1kb 3.1kb
    yellow open customer 5 1 2 0 6.5kb 6.5kb #3. search api
    ➜ ~ curl 'localhost:9200/bank/_search?q=*&pretty'
    {
    "took" : 89, #time in milliseconds for Elasticsearch to execute the search
    "timed_out" : false, #if the search timed out or not
    "_shards" : { #how many shards were searched, as well as a count of the successful/failed searched shards
    "total" : 5,
    "successful" : 5,
    "failed" : 0
    },
    "hits" : { #search results
    "total" : 1000, # total number of documents matching our search criteria
    "max_score" : 1.0,
    "hits" : [ {
    "_index" : "bank",
    "_type" : "account",
    "_id" : "25",
    "_score" : 1.0,
    "_source" : {
    "account_number" : 25,
    "balance" : 40540,
    "firstname" : "Virginia",
    "lastname" : "Ayala",
    "age" : 39,
    "gender" : "F",
    "address" : "171 Putnam Avenue",
    "employer" : "Filodyne",
    "email" : "virginiaayala@filodyne.com",
    "city" : "Nicholson",
    "state" : "PA"
    }
    }, { # instead of passing q=* in the URI, we POST a JSON-style query : Json Query DSL
    ➜ ~ curl -XPOST 'localhost:9200/bank/_search?pretty' -d '
    {
    "query": { "match_all": {} }
    }'
    ➜ ~ curl -XPOST 'localhost:9200/bank/_search?pretty' -d '
    {
    "query": { "match_all": {} },
    "from": 10,
    "size": 10,
    "sort": { "balance": { "order": "desc" } },
    "_source": ["account_number", "balance"] #显示的字段
    }'
    #where条件
    ➜ ~ curl -XPOST 'localhost:9200/bank/_search?pretty' -d '
    {
    "query": { "match": { "account_number": 20 } }
    }' # and or条件查询语法
    ➜ ~ curl -XPOST 'localhost:9200/bank/_search?pretty' -d '
    {
    "query": {
    "bool": {
    "must": [
    { "match": { "address": "mill" } },
    { "match": { "address": "lane" } }
    ]
    }
    }
    }'#"bool":bool型查询 #"must":and "should":or "must_not":neither..nor #范围查询
    ➜ ~ curl -XPOST 'localhost:9200/bank/_search?pretty' -d '
    {
    "query": {
    "bool": {
    "must": { "match_all": {} },
    "filter": {
    "range": {
    "balance": {
    "gte": 20000,
    "lte": 30000
    }
    }
    }
    }
    }
    }' # "gte":大于 "lte":小于 #group by
    #SELECT state, COUNT(*) FROM bank GROUP BY state ORDER BY COUNT(*) DESC
    ➜ ~ curl -XPOST 'localhost:9200/bank/_search?pretty' -d '
    {
    "size": 0,
    "aggs": {
    "group_by_state": {
    "terms": {
    "field": "state"
    }
    }
    }
    }'

Elastic Search(一)的更多相关文章

  1. elastic search查询命令集合

    Technorati 标签: elastic search,query,commands 基本查询:最简单的查询方式 query:{"term":{"title" ...

  2. elastic search 学习笔记

    Elastic search在数据分析的应用中相当于一个数据库的搜索引擎. 跟MySQL类似,它有自己的查询语言,只不过不是关系型数据库,属于NoSQL. 可以根据索引从分布式服务器文件系统中快速存取 ...

  3. elastic search 学习 一

    初步阅读了elastic search 的文档,并使用command实践操作. 大概明白其概念模型.

  4. 分库分表后跨分片查询与Elastic Search

    携程酒店订单Elastic Search实战:http://www.lvesu.com/blog/main/cms-610.html 为什么分库分表后不建议跨分片查询:https://www.jian ...

  5. 自学elastic search

    工作也有一段时间了,虽然来这个公司之后学会了几门不同的语言,但想拨尖还是任重道远. 想往高级程序员甚至是架构师方向发展.他仍然是我的学习对象.我现在做着的,无非是他玩剩下的罢了. luncene之前有 ...

  6. Elastic Search 上市了,市值翻倍,这群人财务自由了!

    国庆长假,大部分人还深浸在风花雪月之中,而就在昨天(美国时间10月5号),我们 Java 程序员所熟知的大名鼎鼎的 Elastic Search 居然在美国纽约证券交易所上市了! 当说到搜索时,大部分 ...

  7. Elastic Search 安装和配置

    目标 部署一个单节点的ElasticSearch集群 依赖 java环境 $java -version java version "1.8.0_161" Java(TM) SE R ...

  8. [elastic search][redis] 初试 ElasticSearch / redis

    现有项目组,工作需要. http://www.cnblogs.com/xing901022/p/4704319.html Elastic Search权威指南(中文版) https://es.xiao ...

  9. elastic search文档详解

    在elastic search中文档(document)类似于关系型数据库里的记录(record),类型(type)类似于表(table),索引(index)类似于库(database). 文档一定有 ...

  10. elastic search 查询

    eelastic search主要有两种查询方式,一种是查询字符串,一种是请求体(json格式)查询. 查询字符串: 查询字符串的功能相对简单,使用容易. 比如GET http://localhost ...

随机推荐

  1. 启动tomcat不出现命令窗口

    有个软件要安装在U盘中,B/S结构,用tomcat做应用服务器,客户要求tomcat不能注册为系统服务,启动时tomcat启动时不能出现命令行窗口,怎么实现? 根据你的问题描述,猜测你的部署系统是Wi ...

  2. 1-3-1 关于API

    主要内容:API函数及其相关内容的介绍.Windows编程相关基础知识介绍 1.API函数的概念 <1>API(Application Programming interface),即应用 ...

  3. URAL 1080 Map Coloring(染色)

    Map Coloring Time limit: 1.0 secondMemory limit: 64 MB We consider a geographical map with N countri ...

  4. poj1611 带权并查集

    题意:病毒蔓延,现在有 n 个人,其中 0 号被认为可能感染,然后给出多个社交圈,如果某个社交圈里有人被认为可能被感染,那么所有这个社交圈里的人都被认为可能被感染,现在问有多少人可能被感染. 带权并查 ...

  5. CSS中控制换行的四种属性

    一.white-space 可以实现HTML中PRE标签的效果,以及单元格的noWrap效果,点此查看示例. Example Source Code 语法: white-space : normal  ...

  6. springMvc源码学习之:spirngMvc的参数注入的问题

    转载:https://my.oschina.net/lichhao/blog/172562 概述 在SpringMVC中,可以使用@RequestBody和@ResponseBody两个注解,分别完成 ...

  7. java Pattern

    public class Test{ //匹配替换掉order by之后的字符串 public static void main(String[] args) { Pattern pattern = ...

  8. EXTJS 5.0 资料

    http://blog.csdn.net/sushengmiyan/article/category/2435029

  9. linux下Redis与phpredis扩展安装

    ++++++++++++++++++++++++++++++++++++++++++++++linux下Redis与phpredis扩展安装++++++++++++++++++++++++++++++ ...

  10. 如何用OCR图文识别软件在文档里复制内容

    ABBYY FineReader 12是一款OCR图文识别软件,可从文档中复制文本.图片和表格,粘贴到其他应用程序中.无需识别整个文档(关于ABBYY FineReader识别文档的文章,请参考解析A ...