KIBANA에서 ELASTICSEARCH CURD하기

code_able·2023년 10월 17일
0

인덱스 생성

PUT test
{
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 1
  },
  "mappings": {
    "properties": {
      "title": {
        "type": "text"
      },
      "content": {
        "type": "text"
      }
    }
  }
}

nori를 세팅하여 인덱스 생성

PUT test
{
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 0,
    "analysis": {
      "tokenizer": {
        "nori_none": {
          "type": "nori_tokenizer",
          "decompound_mode": "none"
        },
        "nori_mixed": {
          "type": "nori_tokenizer",
          "decompound_mode": "mixed"
        },
        "nori_discard": {
          "type": "nori_tokenizer",
          "decompound_mode": "discard"
        }
      },
      "analyzer": {
        "nori_none": {
          "type": "custom",
          "tokenizer": "nori_none",
          "filter": ["lowercase", "nori_readingform"]
        },
        "nori_mixed": {
          "type": "custom",
          "tokenizer": "nori_mixed",
          "filter": ["lowercase", "nori_readingform"]
        },
        "nori_discard": {
          "type": "custom",
          "tokenizer": "nori_discard",
          "filter": ["lowercase", "nori_readingform"]
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "title": {
        "type": "text"
      },
      "content": {
        "type": "text",
        "analyzer": "nori_mixed"
      }
    }
  }
}

인덱스 삭제

DELETE test

create

PUT test/_doc/1
{
  "title":"안녕하세요",
  "content":"반갑습니다"
}

read

GET test/_doc/1

Full Text Query

# 일반적인 match
GET test/_search
{
	"query" : {
		"match" : {
			"content" : "반갑"
		}
	}
}

# or 조건 띄어쓰기로 구분
GET myIndex/_search
{
	"query" : {
		"match" : {
			"content" : "반갑 습니다"
		}
	}
}

# and 조건
GET test/_search
{
	"query" : {
		"match" : {
			"content" : {
				"query" : "반갑 습니다",
				"operator" : "and"
			}
		}
	}
}

기간 검색

GET test/_search
{
  "query": {
    "range": {
      "date": {
        "gt": "2020-01-01"
				"lt" :"2021-01-01"
      }
    }
  }
}

update

POST test/_doc
{
  "content":"반가워용"
}

delete

DELETE test/_doc/1
profile
할수 있다! code able

0개의 댓글