StoryCode

용어

Elastic Search
반응형
Elastic Search RDB
Index Database
Type Table
Document Row
Field Column
Mapping Schema

 

Elastic Search RDB
GET Select
PUT Update
POST Insert
DELETE Delete
반응형

'Elastic Search' 카테고리의 다른 글

[I] FireBeat 설치  (0) 2019.05.20
Logstach 설치  (0) 2019.05.17
KIBANA.샘플데이터 로드  (0) 2019.05.09
KIBANA 설치  (0) 2019.04.30
검색 실행  (0) 2019.04.30

[I] FireBeat 설치

Elastic Search
반응형

1) Download & untar

https://www.elastic.co/kr/downloads/beats/filebeat

https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.0.1-linux-x86_64.tar.gz

 

2) vi filebeat.yml

filebeat-7.0.1-linux-x86_64/usr/local/filebeat-7.0.1-linux-x86_64/filebeat.yml

 

type: log

enabled: true

path: /var/log/*.log

output.elasticsearch: hosts: ["localhost:9200"]

 

3) https://www.elastic.co/guide/en/beats/filebeat/7.0/filebeat-getting-started.html

반응형

'Elastic Search' 카테고리의 다른 글

용어  (0) 2023.08.28
Logstach 설치  (0) 2019.05.17
KIBANA.샘플데이터 로드  (0) 2019.05.09
KIBANA 설치  (0) 2019.04.30
검색 실행  (0) 2019.04.30

Logstach 설치

Elastic Search
반응형

[참조] https://www.elastic.co/guide/kr/logstash/current/installing-logstash.html

 

1) Download & Extract

https://artifacts.elastic.co/downloads/logstash/logstash-7.0.1.tar.gz

 

> sudo su -

> cd /usr/local

> tar zxvf logstash-7.0.1.tar.gz

 

2) Logstash 파이프라인을 생성 테스트 실행테스트

bin/logstash -e 'input { stdin { } } output { stdout {} }'

위 문장을 실행하면 대기모드가 되는데, "hello world" 입력한다.

그럼 결과가 아래와 같이 나타난다.

{
    "@timestamp" => 2019-05-16T23:54:07.736Z,
          "host" => "myhost",
      "@version" => "1",
       "message" => "hello world"
}

Ctrl + D 를 눌러 종료한다.

 

3) 아파치로그 파싱해보기 + FileBeat 을 이용해 Log를 Logstash 로 보내기

  FileBeat 은 log 를 발송하는 Client 측이고, Beats input은 서버측이다.

  Beats input 은 Beats 를 기본 골격으로 하는 FileBeat, PacketBeat, MetricBeat 등을 모두 받아들일 수 있다.

  그리고 이를 Logstash 로 전송한다.

      샘플 데이타 다운로드 : https://download.elastic.co/demos/logstash/gettingstarted/logstash-tutorial.log.gz 

      FileBeat : https://www.elastic.co/kr/downloads/beats/filebeat

                   ( https://github.com/elastic/beats/tree/master/filebeat )

      Beats input : https://www.elastic.co/guide/en/logstash/5.4/plugins-inputs-beats.html

  

  3.1.Download FileBeat 에서 https://www.elastic.co/kr/downloads/beats/filebeat

       https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.0.1-linux-x86_64.tar.gz

  

  3.2.FileBeat 설치

 https://www.elastic.co/guide/en/logstash/5.4/advanced-pipeline.html#configuring-filebeat

 

반응형

'Elastic Search' 카테고리의 다른 글

용어  (0) 2023.08.28
[I] FireBeat 설치  (0) 2019.05.20
KIBANA.샘플데이터 로드  (0) 2019.05.09
KIBANA 설치  (0) 2019.04.30
검색 실행  (0) 2019.04.30

KIBANA.샘플데이터 로드

Elastic Search
반응형

[참조.한글] https://www.elastic.co/guide/kr/kibana/current/tutorial-load-dataset.html

[참조.영문]https://www.elastic.co/guide/en/kibana/current/tutorial-load-dataset.html#_set_up_mappings 

한글과영문은 동일.

한글 매뉴얼은 가끔 오류가 나니 영문 참조하는 걸 권유 (Ex> shakespeare mapping )

 

1)

curl -O https://download.elastic.co/demos/kibana/gettingstarted/7.x/shakespeare.json
curl -O https://download.elastic.co/demos/kibana/gettingstarted/7.x/accounts.zip
curl -O https://download.elastic.co/demos/kibana/gettingstarted/7.x/logs.jsonl.gz

 

 

2)

unzip accounts.zip

unzip logs.jsonl.gz

 

3) 

curl -X PUT "localhost:9200/shakespeare" -H 'Content-Type: application/json' -d'
{
  "mappings": {
    "properties": {
    "speaker": {"type": "keyword"},
    "play_name": {"type": "keyword"},
    "line_id": {"type": "integer"},
    "speech_number": {"type": "integer"}
    }
  }
}
'

 

curl -X PUT "localhost:9200/logstash-2015.05.18" -H 'Content-Type: application/json' -d'
{
  "mappings": {
    "properties": {
      "geo": {
        "properties": {
          "coordinates": {
            "type": "geo_point"
          }
        }
      }
    }
  }
}
'

 

curl -X PUT "localhost:9200/logstash-2015.05.19" -H 'Content-Type: application/json' -d'
{
  "mappings": {
    "properties": {
      "geo": {
        "properties": {
          "coordinates": {
            "type": "geo_point"
          }
        }
      }
    }
  }
}
'

 

curl -X PUT "localhost:9200/logstash-2015.05.20" -H 'Content-Type: application/json' -d'
{
  "mappings": {
    "properties": {
      "geo": {
        "properties": {
          "coordinates": {
            "type": "geo_point"
          }
        }
      }
    }
  }
}
'

 

4) 

curl -H 'Content-Type: application/x-ndjson' -XPOST 'localhost:9200/bank/account/_bulk?pretty' --data-binary "@./download/accounts.json"

 

curl -H 'Content-Type: application/x-ndjson' -XPOST 'localhost:9200/shakespeare/_bulk?pretty' --data-binary "@./download/shakespeare.json"

 

curl -H 'Content-Type: application/x-ndjson' -XPOST 'localhost:9200/_bulk?pretty' --data-binary "@./download/logs.jsonl"

 

 

5) Shakespeare Index Pattern 생성

순서 1) Kibana 5601 port 접속 > 왼쪽 메뉴 Management > Kibana 서브 메뉴> 아래 Index Pattern 클릭

순서 2) Create index pattern 클릭

순서 3) Step 1 of 2: Define index pattern 에서 shakes* 입력후 다음

순서 4) Step 2 of 2: Configure settings 에서 Create index pattern 클릭

 

6) bank Index Pattern 생성

순서 1) Kibana 5601 port 접속 > 왼쪽 메뉴 Management > Kibana 서브 메뉴> 아래 Index Pattern 클릭

순서 2) Create index pattern 클릭

순서 3) Step 1 of 2: Define index pattern 에서 ba* 입력후 다음

순서 4) Step 2 of 2: Configure settings 에서 Create index pattern 클릭

 

7) Logstash Index Pattern 생성

순서 1) Kibana 5601 port 접속 > 왼쪽 메뉴 Management > Kibana 서브 메뉴> 아래 Index Pattern 클릭

순서 2) Create index pattern 클릭

순서 3) Step 1 of 2: Define index pattern 에서 logstash* 입력후 다음

순서 4) @timestamp 선택

순서 5) Step 2 of 2: Configure settings 에서 Create index pattern 클릭

 

8) Kibana 에서 데이터 확인하기.

순서 1) Kibana > 왼쪽 메뉴 Discover 선택

순서 2) 좌측 Filter 아래에서 ba* 선택

순서 3) Filter 에 "account_number<100 AND balance>47500" 입력후 업데이트 클릭하면 결과가 나타난다.

          Filter Bar 우측 "Lucene" 을 클릭하면 On/ Off 나타나는데, Toggle 하면 KQL 로 바꿔야 한다.

* Available Field 에서 add 하면, 원하는 컬럼만 볼 수 있다.

 

9) Kibana 에서 bank 데이터 Visualize 하기.

참고) Visualize 선택시, 우측에 나타나는 목록은 Visaulize 저장된 목록이다.

순서 1) Kibana > 왼쪽 메뉴 Visualize 선택 > 우측 상단 + 클릭 > pie 선택

순서 2) Index Pattern 는 ba* 선택.

순서 3) 왼쪽 중간에 있는 Bucket 메뉴에서 Split Slices 선택.

순서 4) Range 는 Aggregation 선택.
순서 5) Field 는 balance.
순서 6) Range 는 0~999, 1000~2999, 3000~6999, 7000~14999, 15000~30999, 31000~50000 을 입력 후, ▶ (Apply changes) 클릭

순서 7) Save 메뉴 클릭해서 Pie 로 저장.

 

 

10) Kibana 에서 Shakespear 데이터 Visualize 하기.

순서 1) Kibana > 왼쪽 메뉴 Visualize 선택 > 우측 상단 + 클릭 > Vertical bar 선택

순서 2) Index Pattern 는 shake* 선택.

순서 3) 왼쪽 중간에 있는 Metrics 에서, Y-Axis 클릭.

순서 4) Aggregation 을 Unique Count 로 변경, Field 는 Speaker 로 선택. Custom Lable 은 "Speaking Parts"

순서 5) 왼쪽 아래에 있는 Buckets 에서 X-Axis 클릭.
순서 6) Aggregation 을 Terms 으로 설정 및 Field 를 play_name 로 설정.
순서 7) Order by 는 alphabetically 로 설정, Order 는 Ascending으로 설정.
순서 8) custom label 은 "Play Name" 으로 설정.

순서 9) ▶ (Apply changes) 클릭
순서 10) Save 메뉴 클릭해서 Bar 로 저장.

 

11) Kibana 에서 logstach 데이터 Visualize 하기.

순서 1) Kibana > 왼쪽 메뉴 Visualize 선택 > 우측 상단 + 클릭 > Coordinate map 선택

순서 2) Index Pattern 는 logstash* 선택.

순서 3) 상단 Filter 바 우측의 "타임 Picker 바"에서 Absolute / 20150518 ~ 20150520 선택

순서 4) 왼쪽 아래에 있는 Buckets 에서 Geo Coordinates 클릭.

순서 5) Aggregation 을 Geohash  로 설정 및 Field 를 geo.coordinates 선택.
순서 6) 
순서 7) 
순서 8) 

순서 9) ▶ (Apply changes) 클릭
순서 10) Save 메뉴 클릭해서 Bar 로 저장.

 

12) Kibana 에서 

반응형

'Elastic Search' 카테고리의 다른 글

[I] FireBeat 설치  (0) 2019.05.20
Logstach 설치  (0) 2019.05.17
KIBANA 설치  (0) 2019.04.30
검색 실행  (0) 2019.04.30
데이터 탐색.샘플데이터 집합 로드  (0) 2019.04.29

KIBANA 설치

Elastic Search
반응형

1) download

http://wget https://artifacts.elastic.co/downloads/kibana/kibana-7.0.0-linux-x86_64.tar.gz

 

2) tar zxvf kibana...tar.gz

 

3) config/kibana.yml

port : 5601

elastisearch.url : 실제 설치된 주소 지정

X-PACK : elasticsearch.username/ password

외부 접근 허용하기 위해 수정할 부분 : server.host: "0.0.0.0"

 

4) bin/kibana 실행

 

5) 접근

Chrome> http://172.16.174.148:5601

 

반응형

'Elastic Search' 카테고리의 다른 글

Logstach 설치  (0) 2019.05.17
KIBANA.샘플데이터 로드  (0) 2019.05.09
검색 실행  (0) 2019.04.30
데이터 탐색.샘플데이터 집합 로드  (0) 2019.04.29
모든 색인 나열/ 생성  (0) 2019.04.28

검색 실행

Elastic Search
반응형

[ 참조 ] https://www.elastic.co/guide/kr/elasticsearch/reference/current/gs-executing-searches.html

 

1. 검색명령구조

{

    "query":{} # WHERE 조건절

    "size": 10, # 가져올 결과건수

    "_source":["column1", "column2"] # SELECT 컬럼 목록

    "sort":[{"column1":"asc"}] # 정렬

}

 

2. 결과 구조

{

    "took": 걸린시간,

    "timed_out":false,

    "_shards": {},

    "hits":

        "total": 35,

        "max_score" : 

        "hits": [

                    {

                        "_score": # 결과가 얼마나 QUERY 와 매칭되는지

                    },

                    {

                    }

                ]

}

 

 

3. 검색명령.query 조건절 구조

 

{"match":{"account_number":20}}

{"match":{"address":"maill"}} # address에 mill 이라는 용어가 있는 모든 계정 반환

{"match":{"address":"maill lane"}} # address에 mill 혹은 lane 이라는 용어가 있는 모든 계정 반환

{"match_phrase":{"address":"maill lane"}} # address에 "mill lane" 이라는 문구가 있는 모든 계정 반환

{"bool":{"must":[{"match":{"address":"mill"}},{"match":{"address":"lane"}}]}} # address 에 mill 과 lane 이 있는 모든 계정 반환

{"bool":{"must_not":[{"match":{"address":"mill"}},{"match":{"address":"lane"}}]}} # address 에 mill 과 lane 이 없는 모든 계정 반환

{"bool":{"must":[{"match":{"age":"40"}}],{"must_not":[{"match":{"state":"ID"}}]}} # age 가 40 이고, state 가 ID 가 아닌 모든 계정 반환

{"bool":{"should":[{"match":{"address":"mill"}},{"match":{"address":"lane"}}]}} # address 에 mill 혹은 lane 이 있는 모든 계정 반환

 

4. 검색명령.query.filter

{
  "query": {
    "bool": {
      "must": { "match_all": {} },
      "filter": {
        "range": {
          "balance": {
            "gte": 20000,
            "lte": 30000
          }
        }
      }
    }
  }
}

 

5.검색명령.집계

 

- STATE 별로 doc_count = COUNT 결과만 보기.

 size:0 를 설정하여, 검색 적중은 제외하고, 집계만 결과로 본다.

GET /bank/_search
{
  "size": 0,
  "aggs": {
    "group_by_state": {
      "terms": {
        "field": "state.keyword"
      }
    }
  }
}

 

위 집계는 개념상 아래 SQL 과 비슷하다.

SELECT state, COUNT(*) FROM bank GROUP BY state ORDER BY COUNT(*) DESC

 

{
  "took": 29,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits" : {
    "total" : 1000,
    "max_score" : 0.0,
    "hits" : [ ]
  },
  "aggregations" : {
    "group_by_state" : {
      "doc_count_error_upper_bound": 20,
      "sum_other_doc_count": 770,
      "buckets" : [ {
        "key" : "ID",
        "doc_count" : 27
      }, {
        "key" : "TX",
        "doc_count" : 27
      }]
    }
  }
}

 

- STATE 별로 평균balance 얻기

GET /bank/_search

{
  "size": 0,
  "aggs": {
    "group_by_state": {
      "terms": {
        "field": "state.keyword"
      },
      "aggs": {
        "average_balance": {
          "avg": {
            "field": "balance"
          }
        }
      }
    }
  }
}

 

결과

{
    "took": 22,
    "timed_out": false,
    "_shards": {
        "total": 5,
        "successful": 5,
        "failed": 0
    },
    "hits": {
        "total": 1000,
        "max_score": 0,
        "hits": []
    },
    "aggregations": {
        "group_by_state": {
            "doc_count_error_upper_bound": 20,
            "sum_other_doc_count": 770,
            "buckets": [
                {
                    "key": "ID",
                    "doc_count": 27,
                    "average_balance": {
                        "value": 24368.777777777777
                    }
                },
                {
                    "key": "TX",
                    "doc_count": 27,
                    "average_balance": {
                        "value": 27462.925925925927
                    }
                },
                {
                    "key": "AL",
                    "doc_count": 25,
                    "average_balance": {
                        "value": 25739.56
                    }
                },
                {
                    "key": "MD",
                    "doc_count": 25,
                    "average_balance": {
                        "value": 24963.52
                    }
                },
                {
                    "key": "TN",
                    "doc_count": 23,
                    "average_balance": {
                        "value": 29796.782608695652
                    }
                },
                {
                    "key": "MA",
                    "doc_count": 21,
                    "average_balance": {
                        "value": 29726.47619047619
                    }
                },
                {
                    "key": "NC",
                    "doc_count": 21,
                    "average_balance": {
                        "value": 26785.428571428572
                    }
                },
                {
                    "key": "ND",
                    "doc_count": 21,
                    "average_balance": {
                        "value": 26303.333333333332
                    }
                },
                {
                    "key": "ME",
                    "doc_count": 20,
                    "average_balance": {
                        "value": 19575.05
                    }
                },
                {
                    "key": "MO",
                    "doc_count": 20,
                    "average_balance": {
                        "value": 24151.8
                    }
                }
            ]
        }
    }
}

 

 

 

 

 

 

- 연령대별 성별 평균balance 얻기

GET /bank/_search
{
  "size": 0,
  "aggs": {
    "group_by_age": {
      "range": {
        "field": "age",
        "ranges": [
          {
            "from": 20,
            "to": 30
          },
          {
            "from": 30,
            "to": 40
          },
          {
            "from": 40,
            "to": 50
          }
        ]
      },
      "aggs": {
        "group_by_gender": {
          "terms": {
            "field": "gender.keyword"
          },
          "aggs": {
            "average_balance": {
              "avg": {
                "field": "balance"
              }
            }
          }
        }
      }
    }
  }
}

 

결과

{
    "took": 63,
    "timed_out": false,
    "_shards": {
        "total": 5,
        "successful": 5,
        "failed": 0
    },
    "hits": {
        "total": 1000,
        "max_score": 0,
        "hits": []
    },
    "aggregations": {
        "group_by_age": {
            "buckets": [
                {
                    "key": "20.0-30.0",
                    "from": 20,
                    "to": 30,
                    "doc_count": 451,
                    "group_by_gender": {
                        "doc_count_error_upper_bound": 0,
                        "sum_other_doc_count": 0,
                        "buckets": [
                            {
                                "key": "M",
                                "doc_count": 232,
                                "average_balance": {
                                    "value": 27374.05172413793
                                }
                            },
                            {
                                "key": "F",
                                "doc_count": 219,
                                "average_balance": {
                                    "value": 25341.260273972603
                                }
                            }
                        ]
                    }
                },
                {
                    "key": "30.0-40.0",
                    "from": 30,
                    "to": 40,
                    "doc_count": 504,
                    "group_by_gender": {
                        "doc_count_error_upper_bound": 0,
                        "sum_other_doc_count": 0,
                        "buckets": [
                            {
                                "key": "F",
                                "doc_count": 253,
                                "average_balance": {
                                    "value": 25670.869565217392
                                }
                            },
                            {
                                "key": "M",
                                "doc_count": 251,
                                "average_balance": {
                                    "value": 24288.239043824702
                                }
                            }
                        ]
                    }
                },
                {
                    "key": "40.0-50.0",
                    "from": 40,
                    "to": 50,
                    "doc_count": 45,
                    "group_by_gender": {
                        "doc_count_error_upper_bound": 0,
                        "sum_other_doc_count": 0,
                        "buckets": [
                            {
                                "key": "M",
                                "doc_count": 24,
                                "average_balance": {
                                    "value": 26474.958333333332
                                }
                            },
                            {
                                "key": "F",
                                "doc_count": 21,
                                "average_balance": {
                                    "value": 27992.571428571428
                                }
                            }
                        ]
                    }
                }
            ]
        }
    }
}

반응형

데이터 탐색.샘플데이터 집합 로드

Elastic Search
반응형

* 가상 데이타 생성 : www.json-generator.com/

* 샘플 데이터 : https://github.com/elastic/elasticsearch/blob/master/docs/src/test/resources/accounts.json?raw=true

accounts.json
0.23MB

1) 로드 ( accounts.json )

curl -H "Content-Type: application/json" -XPOST 'localhost:9200/bank/account/_bulk?pretty&refresh' --data-binary "@accounts.json"
curl 'localhost:9200/_cat/indices?v'

 

2) 검색 API

- GET /bank/_search?q=*&sort=account_number:asc&pretty

-

GET /bank/_search
{
  "query": { "match_all": {} },
  "sort": [
    { "account_number": "asc" }
  ]
}

 

- Query DSL

GET /bank/_search
{
  "query": { 
    "bool": { 
      "must": [
        { "match": { "title":   "Search"        }}, 
        { "match": { "content": "Elasticsearch" }}  
      ],
      "filter": [ 
        { "term":  { "status": "published" }}, 
        { "range": { "publish_date": { "gte": "2015-01-01" }}} 
      ]
    }
  }
}

 

3) 쿼리 언어 ( term/ match/ match_phrase )

GET /bank/_search
{
  "query": { "match_all": {} }
}

 

GET /bank/_search
{
  "query": { "match_all": {} },
  "size": 1
}

 

GET /bank/_search
{
  "query": { "match_all": {} },
  "from": 10,
  "size": 10
}

 

GET /bank/_search
{
  "query": { "match_all": {} },
  "sort": { "balance": { "order": "desc" } }
}

 

GET /bank/_search
{
  "query": { "match_all": {} },
  "_source": ["account_number", "balance"]
}

 

GET /bank/_search
{
  "query": { "match": { "account_number": 20 } }
}

 

 

 

 

반응형

'Elastic Search' 카테고리의 다른 글

KIBANA 설치  (0) 2019.04.30
검색 실행  (0) 2019.04.30
모든 색인 나열/ 생성  (0) 2019.04.28
매뉴얼-https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html  (0) 2019.04.28
클러스터 상태 보기  (0) 2019.04.28

모든 색인 나열/ 생성

Elastic Search
반응형

1. 색인 나열

> curl http://127.0.0.1:9200/_cat/indices?v


health status index uuid pri rep docs.count docs.deleted store.size pri.store.size

# 색인이 없는 상태

 

2. 색인 생성

> curl -X PUT http://127.0.0.1:9200/customer?pretty # pretty =JSON응답을 pretty-print

{
  "acknowledged" : true,
  "shards_acknowledged" : true
}

 

> curl http://127.0.0.1:9200/_cat/indices?v
health status index    uuid                   pri rep docs.count docs.deleted store.size pri.store.size
yellow open   customer 7K4E9D24SKmUMznoVYcL7w   5   1          0            0       650b           650b

# customer 라는 색인이 하나 있으며, pri shard = 5개, replica = 1개.

# yellow : replica = 1 인데, 노드가 1개뿐임. 노드 추가해야 green 이 됨.

 

 

 

3. 문서 색인화 및 쿼리

호줄할 내용)

PUT /customer/external/1?pretty

{

    "name": "John Doe"

}

 

호출 방법 1.curl)

curl -X PUT -H "Content-Type: application/json; charset=utf-8" -d '{"name":"John Doe"}' http://172.16.174.148:9200/customer/external/1?pretty

 

호출 방법 2.postman)

  PUT + http://172.16.174.148:9200/customer/external/1?pretty 선택

  BODY + raw + json 선택

  { "name": "John Doe" } 입력

 

결과)

{
  "_index" : "customer",
  "_type" : "external",
  "_id" : "1",
  "_version" : 1,
  "result" : "created",
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "failed" : 0
  },
  "created" : true
}

 

* 같은 ID ( 위 경우에는 1 ) 로 한 번 더 호출하면 (이름을 바꿔서) 업데이트(DELETE+INSERT)가 됨.

 

4) 앞서 id=1 로 했으나, 지정하지 않을 수 있다. 이 경우 Random ID 가 사용된다. ( POST 사용)

 

POST /customer/external?pretty
{
  "name": "Jane Doe"
}

 

{
    "_index": "customer",
    "_type": "externa",
    "_id": "AWpnuFPmHm_5zNNoJ_8z",
    "_version": 1,
    "result": "created",
    "_shards": {
        "total": 2,
        "successful": 1,
        "failed": 0
    },
    "created": true
}

 

5) 문서 업데이트

- 문서 업데이트

POST /customer/external/1/_update?pretty

{

  "doc":{"name":"Jane Doe"}

}

- 문서 업데이트 및 필드 추가

POST /customer/external/1/_update?pretty

{

  "doc":{"name":"Jane Doe","age":20}

}

 

- 스크립트를 이용한 업데이트

POST /customer/external/1/_update?pretty

{

  "script":"ctx._source.age += 5"

}

 

6) 문서 삭제

- 한 ID 삭제

DELETE /customer/external/2?pretty

 

- 매칭 삭제

  https://www.elastic.co/guide/en/elasticsearch/reference/5.4/docs-delete-by-query.html

POST twitter/_delete_by_query
{
  "query": { 
    "match": {
      "message": "some message"
    }
  }
}

 

- 전체 삭제

POST twitter,blog/tweet,post/_delete_by_query
{
  "query": {
    "match_all": {}
  }
}

 

7) 배치 처리

- 2개의 Document 인덱싱 처리

POST /customer/external/_bulk?pretty

{"index":{"_id":"1"}}

{"name":"John Doe"}

{"index":{"_id":"2"}}

{"name":"Jane Doe"}

 

- 업데이트와 딜리트 동시 처리. 오류나도 처리는 계속됨. 처리결과반환시에 알수 있음.

POST /customer/external/_bulk?pretty

{"update":{"_id":"1"}}

{"doc":{"name":"John Doe becomes Jane Doe"}}

{"delete":{"_id":"2"}}

 

반응형

'Elastic Search' 카테고리의 다른 글

검색 실행  (0) 2019.04.30
데이터 탐색.샘플데이터 집합 로드  (0) 2019.04.29
매뉴얼-https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html  (0) 2019.04.28
클러스터 상태 보기  (0) 2019.04.28
설치  (0) 2019.04.28

매뉴얼-https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html

Elastic Search
반응형

 

 

https://www.elastic.co/guide/kr/index.html

  https://www.elastic.co/guide/kr/elasticsearch/reference/current/index.html 

  https://www.elastic.co/guide/kr/logstash/current/index.html

  https://www.elastic.co/guide/kr/kibana/current/index.html

 

 

반응형

'Elastic Search' 카테고리의 다른 글

데이터 탐색.샘플데이터 집합 로드  (0) 2019.04.29
모든 색인 나열/ 생성  (0) 2019.04.28
클러스터 상태 보기  (0) 2019.04.28
설치  (0) 2019.04.28
Elastic Search 란  (0) 2019.04.18

클러스터 상태 보기

Elastic Search
반응형

1. curl http://127.0.0.1:9200/_cat/health?v

epoch      timestamp cluster       status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1556456126 12:55:26  elasticsearch green           1         1      0   0    0    0        0             0                  -                100.0%

 

# elasticsearch 가 green 임을 확인 가능.

 

색상 : green/ yellow/ red

녹색 모두 양호한 상태(클러스터가 정상 작동 중)
노란색 모든 데이터가 사용 가능한 상태이지만 일부 리플리카가 아직 배정되지 않은 상태(클러스터는 정상 작동 중)
빨간색

어떤 이유로 일부 데이터가 사용할 수 없는 상태

클러스터가 빨간색이더라도 아직 부분적으로 작동하는 중. = 사용 가능 샤드에서 계속 검색 요청을 처리.

 

데이터가 누락되므로 서둘러 문제를 해결해야 합니다.

 

2. curlcurl http://127.0.0.1:9200/_cat/nodes?v

ip             heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
172.16.174.148            8          40   0    0.01    0.01     0.00 mdi       *      0l3cD0_

 

# 이 클러스트에는 노드="0l3cD0_" 가 유일.

 

 

반응형