'elasticsearch'에 해당되는 글 420건

  1. 2013.07.31 [elasticsearch] Return Field 설명.
  2. 2013.07.16 [Elasticsearch] Native Script 작성 템플릿. (펌)
  3. 2013.07.12 [elasticsearch] get score about nested type document.
  4. 2013.07.01 [Elasticsearch] Request URI 사용 시 검색 성능 관령 옵션.
  5. 2013.06.28 [elasticsearch] query timeout 개념 설명
  6. 2013.06.20 [elasticsearch] path_hierachy 설정
  7. 2013.05.22 [elasticsearch] mapping 분석 및 이해. 5
  8. 2013.05.22 [검색일반] elasticsearch + logstash + kibana
  9. 2013.05.06 [Elasticsearch] What's New in Elasticsearch 0.90?
  10. 2013.04.24 [Elasticsearch] head plugin + http auth plugin

[elasticsearch] Return Field 설명.

Elastic/Elasticsearch 2013. 7. 31. 14:01

elasticsearch 의 검색결과 return field 에 대한 설명 입니다.

뭐 보시면 다 아실만한 내용이긴 합니다.


  • took : 검색질의 응답시간 (milliseconds)
  • timed_out : boolean 값으로 검색엔진 내부에서 질의 실행에 대한 timeout 여부
  • _shards : 검색 수행한 샤드
    • total : 검색 수행한 총 샤드 수
    • successful : 검색 수행을 성공한 샤드 수
    • failed : 검색 수행을 실패한 샤드 수
  • hits : 검색 매칭 결과
    • total : 검색 매칭된 문서 총 수
    • max_score : 매칭된 문서 중 가장 높은 relevant score
    • hits : 매칭된 문서 결과
      • _index : 매칭된 인덱스 명
      • _type : 매칭된 타입 명
      • _id : 매칭된 문서 unique id
      • _score : 매칭된 문서 relevant score
      • _source : 출력 필드 지정을 하지 않았을 경우 리턴, 모든 필드 목록 포함
      • fields : 출력 필드 목록 포함
      • highlight : 강조 필드 목록 포함
  • facets : 그룹 카운팅 결과
    • groupby : 리턴 변수명 (request 시 변수명 지정 가능)
      • _type : facet 유형
      • missing : missing field 에 대한 카운트
      • total : facet 대상 총 수
      • other : facet 대상 총 수에 포함 되지 않은 문서 카운트
      • terms facet terms
        • term : facet 대상 term
        • count : 대상 term 의 카운트


그럼 이런 넘들은 어떤 소스코드를 봐야 할까요?

뭐 당연하겠지만 뭔가의 response 코드를 보면 되겠죠.


대표적인 소스코드는 아래 두개의 클래스를 참고 하시면 됩니다.

SearchResponse.java

InternalSearchResponse.java


:

[Elasticsearch] Native Script 작성 템플릿. (펌)

Elastic/Elasticsearch 2013. 7. 16. 19:21

원본 URL : https://gist.github.com/UpOutServers/9a4466108d12452738e9


package org.elasticsearch.plugin.myplugin;
 
import org.elasticsearch.common.inject.Module;
import org.elasticsearch.plugins.AbstractPlugin;
import org.elasticsearch.rest.RestModule;
import org.elasticsearch.script.ScriptModule;
 
 
public class MyPlugin extends AbstractPlugin {
 
public String name() {
return "MyPlugin";
}
 
public String description() {
return "MyPlugin";
}
 
 
public void onModule(RestModule module) {
module.addRestAction(/*Your rest class*/);
}
 
public void onModule(ScriptModule module) {
module.registerScript(/*Your script name*/ ,/*Your script class*/);
}
}


여기서 제가 만들어서 사용한건 ScriptModule 입니다.

AbstractPlugin 을 이용 할 경우 elasticsearch.yml 에 등록하지 않고 바로 ES 가 실행 되면서 플러그인을 로딩해줘서 설정에 대한 번거로움이 없어집니다.


뭐 등록하는거 만들기 귀찮으시다면 그냥 패쓰 하시면 됩니다.

단, elasticsearch.yml 에 등록을 해주셔야 사용이 가능 하다는 거.. :)


아래는 몇 가지 도움이 될 만한 링크 이니 참고하시면 되겠내요.


http://www.elasticsearch.org/guide/reference/modules/scripting/

https://github.com/imotov/elasticsearch-native-script-example

http://elasticsearch-users.115913.n3.nabble.com/Loading-and-Registering-Native-Scripts-td3088835.html

http://elasticsearch-users.115913.n3.nabble.com/Native-Script-Help-td2980754.html


그리고 매우 중요한건 0.90.x 이랑 아래 버전이랑 API  가 바뀌었으니 꼭 확인하고 사용하시기 바랍니다.

오늘 이것때문에 삽질 했내요..ㅡ.ㅡ;;

:

[elasticsearch] get score about nested type document.

Elastic/Elasticsearch 2013. 7. 12. 15:07

Nested type 의 Document Score 는 구할 수 없습니다.

ㅡ.ㅡ;;

그렇다고 이걸 해결 못하면 안되겠지요.

힌트, nested

:

[Elasticsearch] Request URI 사용 시 검색 성능 관령 옵션.

Elastic/Elasticsearch 2013. 7. 1. 20:23

elasticsearch Rest API 사용 시 검색 질의 성능 관련 파라미터 설명 입니다.

지난 번 보았던 timeout 은 collecting 실행 시간에 대한 제한 이였다면, 

이번에는 이런 문서를 질의 하고 수집 하는데 처리 하는 역할을 수행 하는 쓰레드 관련 설정 입니다.


/_search?operation_threading=threadPerShard


보시는 것 처럼 적용하기 쉽습니다.

이 옵션을 설정 하지 않을 경우 내부적으로 기본 single thread 로 동작 하게 됩니다.

이 경우 request 가 증가 하게 되면 당연히 성능이 떨어 질 수 밖에 없는 구조 입니다.

꼭 해당 옵션을 확인 해서 사용하시기 바랍니다.


아래는 Java API 에서 설정 하는 내용입니다.


.setOperationThreading(SearchOperationThreading.THREAD_PER_SHARD)


관련 소스파일 입니다.


RestSearchAction.java

SearchOperationThreading.java



이외 search_type도 있는데 이건 나중에 살펴 보죠.

:

[elasticsearch] query timeout 개념 설명

Elastic/Elasticsearch 2013. 6. 28. 21:46

elasticsearch 에서의 query timeout 에 대해 설명 합니다.


query timeout 은 두 가지 방법으로 설정이 가능 합니다.

1. Java API

setTimeout(millisecond)

2. Request URI (?timeout=10ms)

timeout=1S

S    : 1S = 1millisecond

ms : millisecond

s : second

m : minute

H : hour

d : day

w : week


기본 millisecond 입니다.


elasticsearch 에서는 query execution 후 중지 시킬 수 없습니다.

즉, timeout 을 지정 했다고 해서 실행 시간이 설정한 timeout 을 넘더라도 실행을 중지 하거나 connection 을 끊거나 하지 않습니다.


shard 들에 질의 후 문서를 collecting 하는데 실행 시간을 제한 하는 기능 입니다.

es 에서 구현된 기능이 아닌 lucene 에서 구현된 기능 입니다.


아래는 이해를 돕기 위한 관련 클래스 파일 입니다.

lucene

TimeLimitingCollector.java

elasticsearch

ContextIndexSearcher.java

TimeValue.java


:

[elasticsearch] path_hierachy 설정

Elastic/Elasticsearch 2013. 6. 20. 15:14

category 나 기타 tree 구조를 갖는 문서속성의 경우 path_hierachy 기능을 사용하면 유용한 부분이 있습니다.

단, 이 기능은 facet 사용은 못하니 참고 하시구요.


{

    "settings" : {

        "index" : {

            "analysis" : {

                "analyzer" : {

                    "path_analyzer" : {"tokenizer" : "path_hierarchy"}

                }

            }

        }

    },

    "mappings" : {

        "category" : {

            "properties" : {

                "category" : {

                    "type" : "multi_field",

                    "fields" : {

                        "name" : { "type" : "string", "index" : "not_analyzed" },

                        "path" : { "type" : "string", "analyzer" : "path_analyzer", "store" : true }

                    }

                }

            }

        }

    }

}



:

[elasticsearch] mapping 분석 및 이해.

Elastic/Elasticsearch 2013. 5. 22. 18:24

elasticsearch 에서 성능 및 운영에 있어서 기본이면서 핵심 내용이 될 수 있는 정보 입니다.

사실 이 내용만 잘 이해 하고 있으면 50% 이상 먹고 들어 갈 수 있습니다. ^^


mapping section

http://www.elasticsearch.org/guide/reference/mapping/


fields 와 types 를 확인해야 함.

fields

_id

document 의 unique id 는 _uid (_id + _type) 이며, _id 는 색인 ID 로 사용될 수 있다.

기본적으로 색인되지 않고 저장 하지 않습니다.

_type

기본적으로 색인은 하지만 저장은 하지 않습니다.

_source

자동으로 field 생성을 허용할지 결정 합니다.

_all

하나 또는 더 많은 field 를 색인시 저장 할 것인지 결정을 합니다.

"simple1" : {"type" : "long", "include_in_all" : true},

"simple2" : {"type" : "long", "include_in_all" : false}

_analyzer (설정 하지 않아도 되는 field)

색인 시 등록된 analyzer 또는 index_analyzer 를 사용 합니다.

또한, 특정 field 를 지정 할 경우 해당 field 에 정의된 analyzer 를 사용하게 됩니다.

_boost

문서나 field 의 연관성을 향상시키기 위해 사용한다.

_parent

parent type 을 지시하는 child mapping 정의 입니다.

blog type 과 blog_tag type 이 있을 경우 blog_tag 의 parent type 은 blog 가 됩니다.

_routing

색인 데이터에 대한 routing 관리를 위해서 사용 합니다.

routing field 는 store : yes, index : not_analyzed 로 설정이 되어야 합니다.

_index (설정 하지 않아도 되는 field)

index 가 소유한 문서를 store 합니다.

default false 로 저장 하지 않음.

_size (설정 하지 않아도 되는 field)

_source 에 의해서 자동으로 생성된 색인 field 의 수.

default disabled 입니다.

_timestamp

색인 시 문서의 timestamp 입니다.

기본 store : no, index : not_analyzed 이며,

설정 시 field 지정이 가능 합니다.

format 은 기본 dateOptionalTime. (http://www.elasticsearch.org/guide/reference/mapping/date-format/)

_ttl

색인 시 문서의 expiration date를 설정 합니다.

기본 disabled 입니다.

설정 시 ttl 이후 문서는 자동 삭제 됩니다.

core types

string type

index_name

array type 선언 시 사용되는 항목으로 array list 항목에 대한 개별 field 명으로 사용된다.

store

default no 이며, 저장에 대한 설정을 위해서 사용 된다.

yes 시 저장

index

검색 또는 색인 시 분석관련 설정을 위해서 사용 된다.

analyzed

검색과 색인 시 analyzer 를 이용해서 분석

not_analyzed

검색가능 하다는 의미

no

검색 불가능 하다는 의미

term_vector

기본 no 설정

no

yes

with_offsets

with_positions

with_positions_offsets

boost

기본 1.0

null_value

null value 시 기본 값은 아무것도 넣지 않으나 설정한 값이 있을 경우 등록 함.

omit_norms

기본 false 로 analyzed field 설정, true 일 경우 not_analyzed field 에서 설정

index_options

색인 옵션

docs

not_analyzed field

freqs

analyzed field

positions

analyzed field

analyzer

global 설정으로 검색과 색인 시 사용된다.

index_analyzer

색인 시에 사용된다.

search_analyzer

검색 시에 사용된다.

include_in_all

기본 true 로 설정 됨.

_all field 에 저장할 것인지 지정함.

ignore_above

지정한 크기 이상의 문자열을 무시 합니다.

position_offset_gap

number type

type : "float, double, byte, short, integer, and long",

index_name

store

index

precision_step

number 의 term value 를 만들어 냅니다.

설정 값이 작을 수록 검색은 빠르게 이루어 집니다.

기본 값은 4이며, 32bits 는 4 정도, 64bits 는 6~8정도를 사용합니다.

0 은 disable 입니다.

null_value

boost

include_in_all

ignore_malformed

비정상적인 숫자를 무시 한다.

기본 false로 설정 되어 있기 때문에 true 설정 하는 것이 좋다.

date type

index_name

format

http://www.elasticsearch.org/guide/reference/mapping/date-format.html

store

index

precision_step

number 의 term value 를 만들어 냅니다.

설정 값이 작을 수록 검색은 빠르게 이루어 집니다.

기본 값은 4이며, 32bits 는 4 정도, 64bits 는 6~8정도를 사용합니다.

0 은 disable 입니다.

null_value

boost

include_in_all

ignore_malformed

비정상적인 숫자를 무시 한다.

기본 false로 설정 되어 있기 때문에 true 설정 하는 것이 좋다.

boolean type

index_name

store

index

null_value

boost

include_in_all

binary type

index_name



default mapping template

"mapping" : {

"TYPE_NAME" : {

"analyzer" : "standard",

"index_analyzer" : "stadnard",

"search_analyzer" : "standard",

"_id" : {

"index" : "not_analyzed",

"store" : "yes",

"path" : "FIELD_NAME"

},

"_type" : {

"index" : "not_analyzed",

"store" : "yes"

},

"_source" : {

"enabled" : "false"

},

"_all" : {

"enabled" : "false"

},

"_boost" : {

"name" : "_boost",

"null_value" : 1.0

},

"_parent" : {

"type" : "PARENT_TYPE_NAME"

},

"_routing" : {

"required" : true,

"path" : "TYPE_NAME.FIELD_NAME"

},

"_timestamp" : {

"enabled" : true,

"path" : "DATE_FIELD_NAME",

"format" : "dateOptionalTime"

},

"properties" : {

"FIELD_NAME" : {

"type" : "string",

"index_name" : ,

"store" : ,

"index" : ,

"term_vector" : ,

"boost" : ,

"null_value" : ,

"omit_norms" : ,

"omit_term_freq_and_positions" : ,

"index_options" : ,

"analyzer" : ,

"index_analyzer" : ,

"search_analyzer" : ,

"include_in_all" : ,

"ignore_above" : ,

"position_offset_gap" : 

},

"FIELD_NAME" : {

"type" : "float, double, byte, short, integer, and long",

"index_name" : ,

"store" : ,

"index" : ,

"precision_step" : ,

"null_value" : ,

"boost" : ,

"include_in_all" : ,

"ignore_malformed" :

},

"FIELD_NAME" : {

"type" : "date",

"index_name" : ,

"format" : ,

"store" : ,

"index" : ,

"precision_step" : ,

"null_value" : ,

"boost" : ,

"include_in_all" : ,

"ignore_malformed" :

},

"FIELD_NAME" : {

"type" : "boolean",

"index_name" : ,

"store" : ,

"index" : ,

"null_value" : ,

"boost" : ,

"include_in_all" : ,

},

"FIELD_NAME" : {

"type" : "binary",

"index_name" : ,

}

}

}

}


:

[검색일반] elasticsearch + logstash + kibana

Elastic/Elasticsearch 2013. 5. 22. 17:47

로그를 수집해서 색인을 하고 검색 결과에 대한 분석 서비스가 나왔내요.

splunk 랑 비슷한 역할을 하는 오픈 소스라 elasticsearch 와 잘 조합해서 사용을 하면 splunk 보다 더 좋은 오픈소스 플랫폼이 나오지 않을까 싶내요.


[오픈소스 링크]

https://github.com/elasticsearch/kibana

http://logstash.net/

https://github.com/elasticsearch/elasticsearch


[주의사항]

index name format : logstash-yyyy.mm.dd

@timestamp : es datetime format

:

[Elasticsearch] What's New in Elasticsearch 0.90?

Elastic/Elasticsearch 2013. 5. 6. 11:58

얼마전에 릴리즈 되고 0.90.0 에 대한 미디오 컨퍼런스(?)도 했었죠.

관련 영상과 발표 문서 공유 합니다.


[영상]

http://info.elasticsearch.com/Recorded_0.90_Webinar.html?mkt_tok=3RkMMJWWfF9wsRonu6rNZKXonjHpfsX56%2BQvWaaxlMI%2F0ER3fOvrPUfGjI4ATMBrI%2BSLDwEYGJlv6SgFQrHGMa1h17gOUhM%3D


[발표문서]

- 위 페이지에도 링크가 있습니다.


What's new in 0.90 5-3-12.pdf



[요약]

- Fuzzy Query 성능 향상

- Similarity 에서는 더 이상 td/idf 를 사용하지 않고 BM25 를 적용해서 사용

- fielddata cache 기능 및 성능 향상

- Multi Value 는 좀 무겁다.

- soft_refs 는 사용하지 마라 (빈번한 GC 사용과 느리다)

- Node Level Cache Control 을 해라

- Common Terms Query 활용

- Search -> Query -> Facets -> Filter -> Rescore 순

- Social Filter(Graph) 기능 향상 (Pareent docs - Child docs)

- Suggester (Shingle token filter) : term bigram 같은...

- Sort on Multi value

- Indices Alias 기능 활용



날로 좋아 지고 있내요.. ^^

:

[Elasticsearch] head plugin + http auth plugin

Elastic/Elasticsearch 2013. 4. 24. 13:26

elasticsearch head plugin 사용하시 외부로 ES 서버가 노출되어 있는 경우 인증 부분을 고민 해야 합니다.

보통은 중간에 proxy 서버를 두어서 gateway 역할을 수행하게 하고 외부로 노출 안시키고 서비스를 할 수 있는데요.

혹시라도 proxy 구조를 두기 어렵다면 기본 인증이라도 적용하는게 좋지 않을까 합니다.


이미 ES 플러그인으로 제공되는 것이 있어서 링크 공유 합니다.


[head plugin]

https://github.com/mobz/elasticsearch-head


[http basic auth plugin]

https://github.com/karussell/elasticsearch-http-basic

: