관련: .mapping 파일
참고 : https://www.elastic.co/guide/en/elasticsearch/reference/current/analyzer.html
Only text fields support the analyzer mapping parameter.
The analyzer parameter specifies the analyzer used for text analysis
when indexing or searching a text field.
Unless overridden with the search_analyzer mapping parameter,
this analyzer is used for both index and search analysis.
참고 : https://www.elastic.co/guide/en/elasticsearch/reference/current/search-analyzer.html
Usually, the same analyzer should be applied at index time and at search time,
to ensure that the terms in the query are in the same format as the terms in the inverted index.
ㄴ 예외 : such as when using the edge_ngram tokenizer for autocomplete or when using search-time synonyms.
ㄴ 일반적으로 색인/검색 시, analyzer 사용하지만 search_analyzer 설정을 통해 더 specify 한다는것 같다
참고 : https://www.elastic.co/guide/en/elasticsearch/reference/current/specify-analyzer.html
Elasticsearch offers a variety of ways to specify built-in or custom analyzers:
ㄴ In most cases, a simple approach works best: Specify an analyzer for each text field
// 1번 사례
PUT my-index-000001
{
"mappings": {
"properties": {
"title": {
"type": "text",
"analyzer": "whitespace"
}
}
}
}
In most cases, specifying a different search analyzer is unnecessary.
Doing so could negatively impact relevancy and result in unexpected search results.
ㄴ 분석기 사용을 꼭 해보라는 말
// 1번 사례
GET my-index-000001/_search
{
"query": {
"match": {
"message": {
"query": "Quick foxes",
"analyzer": "stop"
}
}
}
}
// 2번 사례
PUT my-index-000001
{
"mappings": {
"properties": {
"title": {
"type": "text",
"analyzer": "whitespace",
"search_analyzer": "simple"
}
}
}
}
참고: https://www.elastic.co/guide/en/elasticsearch/reference/current/test-analyzer.html
POST _analyze
{
"analyzer": "whitespace",
"text": "The quick brown fox."
}
POST _analyze
{
"tokenizer": "standard",
"filter": [ "lowercase", "asciifolding" ],
"text": "Is this déja vu?"
}
// 인덱스에 설정된 대로 분석기 돌려볼 수 있다
GET my-index-000001/_analyze
{
"field": "my_text", // 프로퍼티 필드 이름
"text": "Is this déjà vu?"
}