일래스틱서치는 fuzzy query를 지원한다.
Fuzzy query와 Range query의 around 에서 사용하는 내용으로 조금 공부가 필요하다.
일래스틱서치는 내부적으로 사용하는 레펜스타인 알고리즘과 다메라우-레펜스타인 알고리즘, 자로 윙클러, ngram등을 지원하고 있으니, 아래 내용을 미리 살펴보고 이해하는 것이 좋다. 내용은 아래 설명이 잘 되어 있어서 특별히 하지 않는다.
http://ntz-develop.blogspot.de/2011/03/fuzzy-string-search.html
http://juggernaut.tistory.com/14 (한글 번역)
일래스틱서치는 레펜스타인 알고리즘(https://en.wikipedia.org/wiki/Levenshtein_distance)은 편집 거리(modified distance)의 을 사용하고 있다. 이 편집 거리의 개념을 매개변수로 받아들인다.
0, 1, 2
the maximum allowed Levenshtein Edit Distance (or number of edits)
AUTO
generates an edit distance based on the length of the term. For lengths:
0..2
must match exactly
3..5
one edit allowed
>5
two edits allowed
AUTO should generally be the preferred value for fuzziness.
키워드의 유사도 검사시 단순히 유사도 검색 뿐 아니라 오타(전치)까지도 포함하는 알고리즘인 다메라우 레펜스타인 알고리즘은
fuzziness 기본 값은 AUTO가 디폴트일 때 사용될 때 쓰이니 보는 것이 좋은 것 같다..
https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance
실제 elasticsearch에서 suggest 에 관련 거리(distance)
public static StringDistance resolveDistance(String distanceVal) {
if ("internal".equals(distanceVal)) {
return DirectSpellChecker.INTERNAL_LEVENSHTEIN;
} else if ("damerau_levenshtein".equals(distanceVal) || "damerauLevenshtein".equals(distanceVal)) {
return new LuceneLevenshteinDistance();
} else if ("levenstein".equals(distanceVal)) {
return new LevensteinDistance();
//TODO Jaro and Winkler are 2 people - so apply same naming logic as damerau_levenshtein
} else if ("jarowinkler".equals(distanceVal)) {
return new JaroWinklerDistance();
} else if ("ngram".equals(distanceVal)) {
return new NGramDistance();
} else {
throw new IllegalArgumentException("Illegal distance option " + distanceVal);
}
}
일래스틱서치는 XFuzzySuggester 클래스에 다메라우 레펜스타인 알고리즘을 기반으로 하여 좀 더 놓은 Fuzzy 추천 알고리즘을 추가하기도 했다.
참고 :
https://www.elastic.co/guide/en/elasticsearch/reference/1.7/query-dsl-fuzzy-query.html
http://ko.cyclopaedia.asia/wiki/Jaro%E2%80%93Winkler_distance
https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance
'Elasticsearch' 카테고리의 다른 글
[elasticsearch] query_string으로 질의시 유의할 사항 (0) | 2015.10.26 |
---|---|
[elasticsearch] 특정 type의 모든 document 삭제하기 (0) | 2015.10.14 |
elasticsearch는 3.0.0 준비중. (0) | 2015.09.21 |
[elasticsearch] java- multiget 예제 (주의사항) (0) | 2015.09.18 |
[elasticsearch] action.destructive_requires_name (0) | 2015.09.16 |