[ElasticSearch] analyzer, search_analyzer, search_quote_analyzer

Woong·2022년 12월 29일
0

ElasticSearch

목록 보기
14/21

analyzer

  • analyzer : index time 에 사용
  • search_analyzer : non-phase 쿼리에 사용
  • search_quote_analyzer : phase 쿼리에 사용
PUT my-index-000001
{
   "settings":{
      "analysis":{
         "analyzer":{
            "my_analyzer":{ 
               "type":"custom",
               "tokenizer":"standard",
               "filter":[
                  "lowercase"
               ]
            },
            "my_stop_analyzer":{ 
               "type":"custom",
               "tokenizer":"standard",
               "filter":[
                  "lowercase",
                  "english_stop"
               ]
            }
         },
         "filter":{
            "english_stop":{
               "type":"stop",
               "stopwords":"_english_"
            }
         }
      }
   },
   "mappings":{
       "properties":{
          "title": {
             "type":"text",
             "analyzer":"my_analyzer", 
             "search_analyzer":"my_stop_analyzer", 
             "search_quote_analyzer":"my_analyzer" 
         }
      }
   }
}
PUT my-index-000001/_doc/1
{
   "title":"The Quick Brown Fox"
}
PUT my-index-000001/_doc/2
{
   "title":"A Quick Brown Fox"
}
  • ex) search_quote_analyzer 가 적용
    • lowercase, stop_english 필터가 적용
      * -> 관사인 the 가 무시
      • quick, brown, fox 만 기준으로
      • a quick brown fox 도 검색된다.
GET my-index-000001/_search
{
   "query":{
      "query_string":{
         "query":"\"the quick brown fox\"" 
      }
   }
}

reference

0개의 댓글