'Fields'에 해당되는 글 6건

  1. 2021.10.07 [Logstash] Event, Fields 데이터 사용방법
  2. 2016.11.01 [Elasticsearch] Multi fields 질의
  3. 2015.12.22 [Elasticsearch - The Definitive Guide] Single Query String
  4. 2015.12.15 [Elasticsearch] multi match query types
  5. 2013.04.16 [elasticsearch] Core API - Search
  6. 2013.04.16 [elasticsearch] Java API : mapping property.

[Logstash] Event, Fields 데이터 사용방법

Elastic/Logstash 2021. 10. 7. 19:40

logstash 사용 시 event, fields 데이터 사용방법에 대한 공홈 레퍼런스 문서 입니다.
처음 사용하시는 분들에게는 유용한 자료라고 생각 되어서 공유 합니다.

https://www.elastic.co/guide/en/logstash/current/event-api.html
https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html

:

[Elasticsearch] Multi fields 질의

Elastic/Elasticsearch 2016. 11. 1. 13:33

요즘 추천 데이터 만드느라 도통 mapping 정보 설계나 dsl 작성을 안했더니 까먹기 일수내요.

그래서 그냥 기억하는 차원에서 가볍게 작성해 봅니다.


[참고문서]

https://www.elastic.co/guide/en/elasticsearch/reference/2.4/multi-fields.html


[설명]

- 예전에는 multi-field 라고 했고 지금은 fields 라고 합니다.

- fields 의 용도는 단일 field 에 여러가지 속성을 부여하고 싶을 때 사용을 합니다.


예를 들면)

- index:analyzed 로 선언을 했는데 정렬을 해야 할 경우.

- index:not_analyzed 로 선언을 했는데 같은 value로 fulltext 검색을 해야 할 경우.


보통은 index:analyzed 로 선언 하고 fields 로 index:not_analyzed 로 구성 하는게 많습니다.


[mappings 정보]

...중략...

"keyword": { "type":"string", "index":"analyzed", "analyzer":"edge_ngram_analyzer", "index_options":"docs", "norms": { "enabled":false },

  "fields": {

    "exact": {

      "type":"string", "index":"not_analyzed", "store":"no"

    }

  }

},

...중략...

- 위 맵핑 정보는 제가 자동완성에서 사용하는 정보를 일부 발췌한 내용입니다.


[query dsl]

{

  "query": {

    "term": {

      "keyword.exact": "향수"

    }

  }

}

- 질의는 위에서와 같이 .(dot) 을 이용해서 field 명을 사용하시면 됩니다.

:

[Elasticsearch - The Definitive Guide] Single Query String

Elastic/TheDefinitiveGuide 2015. 12. 22. 11:13

여러 필드에 질의 할 때 문서에 대한 score 계산시 가장 relevant 한 결과를 만들어 내기 위해 사용하는 기법이라고 보면 될 것 같습니다.

하지만 기능적으로 어떤의미를 갖는지를 알아야 응용이 가능 하겠습니다.


원문링크)


원문 Snippet)

Best fields
When searching for words that represent a concept, such as “brown fox,” the words mean more together than they do individually. Fields like the title and body, while related, can be considered to be in competition with each other. Documents should have as many words as possible in the same field, and the score should come from the best-matching field.
Most fields

A common technique for fine-tuning relevance is to index the same data into multiple fields, each with its own analysis chain.

The main field may contain words in their stemmed form, synonyms, and words stripped of theirdiacritics, or accents. It is used to match as many documents as possible.

The same text could then be indexed in other fields to provide more-precise matching. One field may contain the unstemmed version, another the original word with accents, and a third might use shinglesto provide information about word proximity.

These other fields act as signals to increase the relevance score of each matching document. The more fields that match, the better.

Cross fields

For some entities, the identifying information is spread across multiple fields, each of which contains just a part of the whole:

  • Person: first_name and last_name
  • Book: title, author, and description
  • Address: street, city, country, and postcode


가볍게 요약하면 이렇습니다.

- best fields 는 가장 적합한 field 의 score 를 리턴 합니다.

- most fields 는 field 들의 score 를 더한 값을 리턴 합니다.

- cross fields 는 field 들을 섞어서 score 를 계산 하여 리턴 합니다. (field 들 중 최소의 idf 값을 사용 합니다.)


:

[Elasticsearch] multi match query types

Elastic/Elasticsearch 2015. 12. 15. 10:39

multi match query 에서 사용하는 type 설명 입니다.

그냥 소스코드에서 발췌 했습니다.


[MultiMatchQueryBuilder.java]

/**
* Uses the best matching boolean field as main score and uses
* a tie-breaker to adjust the score based on remaining field matches
*/
BEST_FIELDS(MatchQuery.Type.BOOLEAN, 0.0f, new ParseField("best_fields", "boolean")),

/**
* Uses the sum of the matching boolean fields to score the query
*/
MOST_FIELDS(MatchQuery.Type.BOOLEAN, 1.0f, new ParseField("most_fields")),

/**
* Uses a blended DocumentFrequency to dynamically combine the queried
* fields into a single field given the configured analysis is identical.
* This type uses a tie-breaker to adjust the score based on remaining
* matches per analyzed terms
*/
CROSS_FIELDS(MatchQuery.Type.BOOLEAN, 0.0f, new ParseField("cross_fields")),

/**
* Uses the best matching phrase field as main score and uses
* a tie-breaker to adjust the score based on remaining field matches
*/
PHRASE(MatchQuery.Type.PHRASE, 0.0f, new ParseField("phrase")),

/**
* Uses the best matching phrase-prefix field as main score and uses
* a tie-breaker to adjust the score based on remaining field matches
*/
PHRASE_PREFIX(MatchQuery.Type.PHRASE_PREFIX, 0.0f, new ParseField("phrase_prefix"));


:

[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.



:

[elasticsearch] Java API : mapping property.

Elastic/Elasticsearch 2013. 4. 16. 10:57

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

정보 교환이 목적입니다.


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

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



[elasticsearch java api 리뷰]

원문 링크

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


이번 문서는 Java API에서도 제공하고 있는 mapping 관련 설정 값들 입니다.

자세한 설명은 원문의 Fields 와 Types 부분은 꼭 한번 씩 보시기 바랍니다.


[Mapping Template Sample]

    "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" : ,

                }

            }

        }

    }



[Fields & Core Type]

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

: