1. 인덱스, 매핑 생성 (은전한닢 분석기 적용)

PUT msis
{
  "settings" : {
    "index":{
      "analysis":{
        "analyzer":{
          "korean":{
            "type":"custom",
            "tokenizer":"seunjeon_default_tokenizer"
          }
        },
        "tokenizer": {
          "seunjeon_default_tokenizer": {
            "type": "seunjeon_tokenizer",
            "user_words": ["낄끼빠빠,-100", "버카충", "abc마트"]
          }
        }
      }
    }
  },
  "mappings": {
    "company": {
      "properties": {
        "title": {
          "type": "text"
        },
        "contents": {
          "type": "text",
          "analyzer": "korean"
        }
      }
    }
  }
}

2. 테스트 데이터입력 (2건등록)

POST msis/company
{
	"title":"한국 프로야구", 
	"contents" : "해태타이거즈가 기아타이거즈가 되고, 빙그레이글스가 한화이글스가 되고요."
}

POST msis/company
{
	"title":"한국 프로야구", 
	"contents" : "한화이글스 올해는 꼴찌 예약 ㅠㅜ"
}

3. 검색

GET msis/company/_search 
{
  "query": {
    "match": {
      "contents": "한화"
    }
  }
}

 

기본적인 사용법을 적어봤다.

+ Recent posts