본문 바로가기

IT/Elasticsearch

[Elasticsearch] -H 'Content-Type: application/json' 5.5.0 이상 버전에서 아래와 같은 에러 발생 시 {"error":"Content-Type header [application/x-www-form-urlencoded] is not supported","status":406} 커맨드 끝에 아래처럼 타입을 설정해줘야한다. (불편불편...) -H 'Content-Type: application/json' Example)curl -XPUT '11.123.45.67:9200/myindex/_settings' -d '{ "index" : {"number_of_replicas" : 0}}' -H 'Content-Type: application/json 더보기
[Elasticsearch] snapshot (backup) 생성 #Elasticsearch (5.0.1) snapshot 생성 1. config path.repo: ["[MOUNT_PATH]"] 2. restart all nodes 3. create backup curl -XPUT '[IP]:9200/_snapshot/my_backup' -d '{ "type": "fs", "settings": { "location": "[MOUNT_PATH]", "compress": true } }' 4. check curl -XGET '[IP]:9200/_snapshot/my_backup?pretty' 5. excute curl -XPUT '[IP]:9200/_snapshot/my_backup/snapshot_20170801?wait_for_completion=true&pretty.. 더보기
[Elasticsearch] php에서 elasticsearch 다루기 # composer.json 파일 생성 후 아래 내용 입력{ "require": { "elasticsearch/elasticsearch": "~5.0" }} # composer.json 위치에서 다운로드curl -s http://getcomposer.org/installer | phpphp composer.phar install --no-dev # 사용하고자 하는 php에 생성된 "vendor" 디렉토리를 옮긴 후 아래와 같이 사용require 'vendor/autoload.php';use Elasticsearch\ClientBuilder; $client = ClientBuilder::create()->build(); 출처 : https://www.elastic.co/guide/en/elasticsear.. 더보기
[delete_by_query] 쿼리 & 삭제 무슨 플러그인을 깔아야 한다고 하던데 그건 2.X 버전에서만 그런가보다... 5.0.1 기준으로 플러그인 없이 순식간에 삭제가 되는걸 볼 수 있다. curl -POST '112.293.59.20:9200/myindex/mytype/_delete_by_query?pretty' -d '{ "query": { "match": { "name": "Kim" } }}' 더보기
[Elasticsearch] 성능 극대화 #색인시 bulk API 사용하기 - 한번에 다수의 문서를 색인하는 방법이다. echo '{"index" : {"_index" : "get-together", "_type" : "group"}}{"name" : "Elasticsearch Bucharest"}{"index" : {"_index" : "get-together", "_type" : "group"}}{"name" : "Big Data Bucharest"}' > test_bulk.jsoncurl -XPOST localhost:9200/get-together/_bulk --data-binary @test_bulk.json - 아래와같이 rest api 호출시 index, type을 지정하면, json에 index, type 생략이 가능하다.echo.. 더보기
[Elasticsearch] 스케일 아웃 #노드 해체하기 curl -XPUT 'localhost:9200/_cluster/settings' -d '{"transient" : {"cluster.routing.allocation.exclude._ip" : "192.168.1.10"}}' - 재시작을 원하는 노드를 그냥 종료하면 데이터의 손실이다. 위와같이 하면 (192.168.1.10은 해당 노드의 ip) 노드의 데이터들을 다른 노드들이 나눠가지면서 클러스터 green 상태를 유지하면서 재시작이 가능하다. ### 일반적으로 루씬 색인은 21억건 이상의 문서 혹은 2740억건 이상의 고유 텀들을 가질 수 없다. (p410) #롤링 리스타트 - 노드 업그레이드 혹은 설정값을 바꿀 때, 데이터 가용성을 해치지 않으면서 재구동을 하는 방법이다. 과정은 다.. 더보기
[Elasticsearch] Elasticsearch In Action - 7 7.1.1 집계 요청의 구조 curl 'localhost:9200/get-together/group/_search?pretty' -d '{"aggs" : {"top_tags" : {"terms" : {"field" : "tags.verbatim"}}}}' curl 'localhost:9200/get-together/group/_search?pretty' -d '{"query" : {"match" : {"location_group" : "Denver"}},"aggregations" : {"top_tags" : {"terms" : {"field" : "tags.verbatim"}}}}' 더보기
[Elasticsearch] Elasticsearch In Action - 6 유사도 검색 6.1 일래스틱서치에서 점수를 계산하는 방법 #elasticsearch에서의 기본 점수 계산법은 TF-IDF를 기본으로 한다.이는 TF(Term Frequency - 텀의 빈도)의 제곱근 X IDF(Inverse Document Frequency - 텀에 대한 역 문서 빈도의 제곱)X norm(정규화 지수 : 단어의 길이에 반비례) * boost 이다. (p.243) 6.2 다른 점수 방법 #BM25 : 유사도 모듈을 반영 {"mappings" : {"get-together" : {"properties" : {"title" : "string","similarity" : "BM25"}}}} 6.3 부스팅 #색인 혹은 재색인시에 boost를 줄 수 있는데, 질의 시점에 부스팅을 사용하는걸 추천한다.(이유는 .. 더보기
[Elasticsearch] Analyzer #한글 형태소분석기- http://github.com/chanil1218/elasticsearch-analysis-korean- bin/plugin url https://dl-web.dropbox.com/spa/grpekzky9x5y6mc/elastic-analysis-korean/public/elasticsearch-analysis-korean-1.3.0.zip -install analysis-korean#은전한잎- http://bakyeono.net/post/2016-06-03-start-elasticsearch.html- bin/plugin install org.bitbucket.eunjeon/elasticsearch-analysis-seunjeon/2.3.3.0 더보기
[Elasticsearch] download url wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.0.2.tar.gz curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.0.1.tar.gz 더보기