'preference'에 해당되는 글 2건

  1. 2014.08.26 [ElasticSearch] 자꾸 까먹어..ㅡ.ㅡ;; (preference)
  2. 2013.04.16 [elasticsearch] Core API - Search

[ElasticSearch] 자꾸 까먹어..ㅡ.ㅡ;; (preference)

Elastic/Elasticsearch 2014. 8. 26. 14:26


http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-preference.html


preference

Controls a preference of which shard replicas to execute the search request on. By default, the operation is randomized between the shard replicas.

The preference is a query string parameter which can be set to:

_primary

The operation will go and be executed only on the primary
 shards.

_primary_first

The operation will go and be executed on the primary shard,
and if not available (failover), will execute on other shards.

_local

The operation will prefer to be executed on a local allocated
shard if possible.

_only_node:xyz

Restricts the search to execute only on a node with the
provided node id (xyz in this case).

_prefer_node:xyz

Prefers execution on the node with the provided node id
(xyz in this case) if applicable.

_shards:2,3

Restricts the operation to the specified shards. (2 and 3 
in this case). This preference can be combined
with other preferences but it has to appear first: _shards:2,3;_primary

Custom (string) value

A custom value will be used to guarantee that
the same shards will be used for the same custom value.
This can help with "jumping values" when hitting different
shards in different refresh states. A sample value can be
something like the web session id, or the user name.


:

[elasticsearch] Core API - Search

Elastic/Elasticsearch 2013. 4. 16. 18:43

본 문서는 개인적인 테스트와 elasticsearch.org 그리고 community 등을 참고해서 작성된 것이며,

정보 교환이 목적입니다.


잘못된 부분에 대해서는 지적 부탁 드립니다.

(예시 코드는 성능 및 보안 검증이 되지 않았습니다.)



[elasticsearch API 리뷰]

원문 링크 : http://www.elasticsearch.org/guide/reference/api/search/


[Filter]

- http://www.elasticsearch.org/guide/reference/api/search/filter/

- 실행한 query 결과를 바탕으로 filtering 할 수 있는 옵션


[Rescore]

- http://www.elasticsearch.org/guide/reference/api/search/rescore/

- search_type 이 scan 또는 count 일 경우 실행 되지 않음

- query 와 filter 를 통해서 결과를 return 함.


[Highlight]

- http://www.elasticsearch.org/guide/reference/api/search/highlighting.html

- store : yes 와 term_vector : with_positions_offsets 설정이 되어 있어야 함.

- query 생성 시 아래와 같은 속성으로 설정

highlight

    .pre_tags

    .post_tags

    .tags_schema

    .fields


[Highlighted Fragments]

{
    "query" : {...},
    "highlight" : {
        "order" : "score",
        "fields" : {
            "content" : {"fragment_size" : 150, "number_of_fragments" : 3}
        }
    } 

}

{
    "query" : {...},
    "highlight" : {
        "fields" : {
            "_all" : {},
            "bio.title" : {"number_of_fragments" : 0}
        }
    }
}

- highlight character size = fragment_size (기본 100)

- highlight size = number_of_fragments (기본 5)

- number_of_fragments=0 이면 highlight 된 전체 내용을 return 함.

- boundary characters 는

    . boundary_chars 와 boundary_max_scan 속성을 갖는다.


[Fields]

- http://www.elasticsearch.org/guide/reference/api/search/fields.html

- 검색 결과에 화면에 보여주기 위한 field 를 정의 함

- 기본 store : yes 설정이 되어야 하면 no 라면 _source  값을 load 하게 됨.


[Script Fields]

- http://www.elasticsearch.org/guide/reference/api/search/script-fields/

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

- 쿼리 결과에 대한 별도의 연산 작업을 통해 지정한 field 명으로 연산된 값을 return 한다.

{

"query" : { ... }, "script_fields" : { "test1" : { "script" : "doc['my_field_name'].value * 2" }, "test2" : { "script" : "doc['my_field_name'].value * factor", "params" : { "factor" : 2.0 } } } 

}


Its important to understand the difference between doc['my_field'].value and _source.my_field.


[Preference]

- http://www.elasticsearch.org/guide/reference/api/search/preference/

- 검색 요청 시 shard control 을 통해서 사용


[Term Facet]

- http://www.elasticsearch.org/guide/reference/api/search/facets/terms-facet/

{ "query" : { "match_all" : { } }, "facets" : { "tag" : { "terms" : { "field" : "tag", "size" : 10, "order" : "term" } } }

}

- tag field 에서 가장 빈번한 term(size) 10 개, ordering 은 term 으로 수행.

- ordering option 은 count, term, reverse_count, reverse_term (기본 count)


[Range Facet]

- http://www.elasticsearch.org/guide/reference/api/search/facets/range-facet/

- range facet 을 사용하기 위해서는 IndexNumericFieldData(RangeFacetExecutor.java) 를 가져야 함.

- key and value 에서는 key 는 range 비교 항목으로 사용하고, value 는 비교된 결과에 aggregate 연산(total)을 함

- script key and value 사용 가능 함

{ "query" : { "match_all" : {} }, "facets" : { "range1" : { "range" : { "key_script" : "doc['date'].date.minuteOfHour", "value_script" : "doc['num1'].value", "ranges" : [ { "to" : 50 }, { "from" : 20, "to" : 70 }, { "from" : 70, "to" : 120 }, { "from" : 150 } ] } } }

}


[Statistical Facet]

Statistical facet allows to compute statistical data on a numeric fields. The statistical data include count, total, sum of squares, mean (average), minimum, maximum, variance, and standard deviation. 

- numeric fields 에 대해서 통계적 데이터를 계산함.

- script field 와 multi field 지원 함.


[Term Stats Facet]

- term 과 statistical 조합

- size 속성의 기본 값은 10

- size 가 0 인 경우 전체 matching term 을 return 한다. (주의, 너무 많은 결과가 나올 수 있음)

- ordering 옵션은 아래와 같다.

term, reverse_term, count, reverse_count, total, reverse_total, min, reverse_min, max, reverse_max, mean, reverse_mean. Defaults to count.



: