[Elasticsearch] Formatting Synonyms 알아보기

Elastic/Elasticsearch 2016. 2. 26. 14:48
synonym 구성을 어떻게 하는지 궁금해 하시는 분들이 있을 것 같아 정리해 봅니다.

내용은 elastic.co 의 "The Definitive Guide"에서 가져왔습니다.


[원문 링크]


[원문 Snippet]

In their simplest form, synonyms are listed as comma-separated values:

"jump,leap,hop"

If any of these terms is encountered, it is replaced by all of the listed synonyms. For instance:

Original terms:   Replaced by:
────────────────────────────────
jump             (jump,leap,hop)
leap             (jump,leap,hop)
hop              (jump,leap,hop)

Alternatively, with the => syntax, it is possible to specify a list of terms to match (on the left side),
and a list of one or more replacements (on the right side):

"u s a,united states,united states of america => usa"
"g b,gb,great britain => britain,england,scotland,wales"
Original terms:   Replaced by:
────────────────────────────────
u s a            (usa)
united states    (usa)
great britain    (britain,england,scotland,wales)

If multiple rules for the same synonyms are specified, they are merged together.
The order of rules is not respected. Instead, the longest matching rule wins.
Take the following rules as an example:

"united states            => usa",
"united states of america => usa"

If these rules conflicted, Elasticsearch would turn United States of America into the terms (usa),(of),
(america)
. Instead, the longest sequence wins, and we end up with just the term (usa).


두 가지 방법으로 설정 하는 예제가 나와 있습니다.


Case 1) "jump,leap,hop" 과 같이 double quotation 으로 묶는 방법

색인 시 jump 라는 term 이 발생 하게 되면 leap, hop 두 개의 term 이 추가 되어서 색인이 되게 됩니다.

그렇기 때문에 색인 크기가 증가 되는 이슈가 있을 수 있습니다.


Case 2) => 기호를 사용한 양자택일 방법

이 방법은 왼쪽에 있는 term을 오른쪽에 있는 term으로 replacement 하게 됩니다.



: