• es中文社区
    1. https://github.com/elasticsearch-cn
  • es权威指南
    1. https://es.xiaoleilu.com/
      https://elasticsearch.cn/book/elasticsearch_definitive_guide_2.x/
  • 搜索类型
      es在查询时,可以指定搜索类型为QUERY_THEN_FETCH,QUERY_AND_FEATCH,DFS_QUERY_THEN_FEATCH和DFS_QUERY_AND_FEATCH
      http://www.cnblogs.com/donlianli/p/3857500.html
      https://www.elastic.co/blog/understanding-query-then-fetch-vs-dfs-query-then-fetch
  • 常用插件:
    1. sql
      如果查询不会写可以用这个 看看他的dsl
      https://github.com/NLPchina/elasticsearch-sql
      header
      https://github.com/mobz/elasticsearch-head
  • 相关资料
    1. exploring elasticsearch http://exploringelasticsearch.com/github_interview.html
      #研发解决方案介绍#基于ES的搜索+筛选+排序解决方案 https://www.cnblogs.com/zhengyun_ustc/p/55solution6.html
  • hadoop集成
    1. https://www.elastic.co/guide/en/elasticsearch/hadoop/current/configuration.html
  • hive集成
    1. https://www.elastic.co/guide/en/elasticsearch/hadoop/current/hive.html
      https://mvnrepository.com/artifact/org.elasticsearch/elasticsearch-hadoop/5.6.11
    常用命令:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    查看索引
    http://127.0.0.1:9200/_cat/indices?v

    curl -i -XGET 'http://127.0.0.1:9200/_count?pretty'

    新增数据
    curl -i -XPOST 'http://127.0.0.1:9200/com/employee/1' -d'{"first_name":"John","last_name":"Smith","age":25,"about":"i love go rock climbing","interests":["sport","music"]}'
    curl -i -XGET 'http://127.0.0.1:9200/com/employee/1?pretty'

    curl -i -XPOST 'http://127.0.0.1:9200/com/employee/2' -d'{"first_name":"weimingwei","last_name":"mingming","age":20,"about":"i love go rock climbing","interests":["music"]}'
    curl -i -XPOST 'http://127.0.0.1:9200/com/employee/3' -d'{"first_name":"yang","last_name":"wenshuai","age":60,"about":"good good study day day up ","interests":["painting"]}'
    curl -i -XPOST 'http://127.0.0.1:9200/com/employee/4' -d'{"first_name":"66777","last_name":"324234324","age":60,"about":"good good study day day up ","interests":["painting"]}'

    简单搜索:
    curl -i -XGET 'http://127.0.0.1:9200/com/employee/_search?pretty'
    curl -i -XGET 'http://127.0.0.1:9200/com/employee/_search?q=last_name=wenshuai&pretty'
    复杂查询
    curl -i -XGET 'http://127.0.0.1:9200/com/employee/_search' -d'
    {
    "query": {
    "filtered": {
    "filter": {
    "range": {
    "age": {
    "gt": 30
    }
    }
    },
    "query": {
    "match": {
    "last_name": "mingwei"
    }
    }
    }
    }
    }'

    全文搜索
    curl -i -XGET 'http://127.0.0.1:9200/com/employee/_search?pretty' -d'
    {

    "query": {
    "match": {
    "about": "love"
    }
    }

    }'

    curl -i -XPUT 'http://127.0.0.1:9200/twitter/_settings?pretty' -d'{"number_of_shards":1,"number_of_replicas":2}'

    任意往里面放数据
    curl -i -XPUT 'http://127.0.0.1:9200/web/nn/123?pretty' -d'{"number_of_shards":1,"number_of_replicas":2}'
    curl -XGET 'http://127.0.0.1:9200/web/nn/123?pretty'
    {
    "_index" : "web",
    "_type" : "nn",
    "_id" : "123",
    "_version" : 1,
    "found" : true,
    "_source" : {
    "number_of_shards" : 1,
    "number_of_replicas" : 2
    }

    过滤字段获取
    curl -XGET 'http://127.0.0.1:9200/web/nn/123?_source=number_of_shards&pretty'
    {
    "_index" : "web",
    "_type" : "nn",
    "_id" : "123",
    "_version" : 1,
    "found" : true,
    "_source" : {
    "number_of_shards" : 1
    }
    只要source
    curl -XGET 'http://127.0.0.1:9200/web/nn/123/_source?pretty'
    {
    "number_of_shards" : 1,
    "number_of_replicas" : 2
    }

    检查是否存在 curl -i -XHEAD 'http://127.0.0.1:9200/web/nn/133' -I

    删除
    curl -XPOST http://10.0.12.108:6335/app_subjoin_renewal_data_di/app_subjoin_renewal_data_di/_delete_by_query -d'
    {"query":{"bool":{"filter":[{"match_phrase":{"date":20180131}}]}}}'

    删除所有:
    curl -XPOST '10.0.9.108:9200/homework/minactivtyfinish/_delete_by_query?conflicts=proceed&pretty' -d'
    {
    "query": {
    "match_all": {}
    }
    }'

    curl -XPOST 'http://10.0.12.110:6335/app_service_tms_teacher_statics_da/app_service_tms_teacher_statics_da/_delete_by_query?conflicts=proceed&pretty' -d'{"query": {"range" : "update_time" : {
    "lt" :
    }
    }
    }
    }'

    中文问题
    curl -i -XPOST 'http://127.0.0.1:9200/com/employee/1' -d'{"first_name":"王伟伟","last_name":"王雪峰","age":25,"about":"i love go rock climbing","interests":["sport","music"]}'

    curl 'http://127.0.0.1:9200/com/employee/_search?pretty' -d'
    {
    "query": {
    "prefix" : { "first_name" : "王伟" }
    }
    }'

    curl 'http://127.0.0.1:9200/com/employee/_search?pretty' -d'
    {
    "query": {
    "prefix" : { "last_name" : "王" }
    }
    }'

    curl -XGET 'http://10.0.12.110:6335/app_es_rpt_kpi_teacher_structure_di/app_es_rpt_kpi_teacher_structure_di/_search?pretty'

    curl 'http://127.0.0.1:9200/com/employee/_search?pretty' -d'
    { "query": {
    "prefix" : { "last_name" : "wen" }
    }
    }

    '

    #scroll
    curl http://10.1.1.246:9200/app_runup_new_teacher_data_di/app_runup_new_teacher_data_di/_search?scroll=1m -d'
    {
    "query": { "match_all": {}},
    "sort" : ["_doc"], //the most efficient sort order
    "size": 10
    }'

    curl http://10.1.1.246:9200/_search/scroll -d'
    {
    "scroll": "1m",
    "scroll_id" : "DnF1ZXJ5VGhlbkZldGNoBQAAAAAACzEGFnI2WFh1RDVJVEt5RERKZ0xhRXZnckEAAAAAAAsxBxZyNlhYdUQ1SVRLeURESmdMYUV2Z3JBAAAAAAALMQgWcjZYWHVENUlUS3lEREpnTGFFdmdyQQAAAAAACzEKFnI2WFh1RDVJVEt5RERKZ0xhRXZnckEAAAAAAAsxCRZyNlhYdUQ1SVRLeURESmdMYUV2Z3JB"
    }'

    删除索引

    curl -XDELETE '10.0.12.108:6335/bi_app_subjoin_renewal_data_flag_di?pretty'
    curl -XDELETE '10.0.12.108:6335/bi_app_subjoin_renewal_data_di?pretty'

    curl -XDELETE '10.0.12.108:6335/app_subjoin_renewal_data_flag_di?pretty'
    curl -XDELETE '10.0.12.108:6335/app_subjoin_renewal_data_di?pretty'