티스토리 뷰
kibana로 elasticsearch query 생성하는 방법
kibana 다운로드 후 압축 풀면 해당 config/kibana.yml이 존재한다
kibana.yml의 ip, id, pw를 수정하고
cmd로 해당 폴더/bin/kibana.bat을 실행하고 기다리면
localhost:5601로 서버가 떴다고 나온다.
첫번째에 있는 나침반 아이콘을 누르고 들어가면 해당 페이지가 든다
filter에 사용할 조건들을 모두 기입한 후 맨 오른쪽에 update 버튼을 누른 후
Inspect -> Request를 확인하면
{
"version": true,
"size": 500,
"sort": [
{
"createDate": {
"order": "desc",
"unmapped_type": "boolean"
}
}
],
"_source": {
"excludes": []
},
"aggs": {
"2": {
"date_histogram": {
"field": "createDate",
"fixed_interval": "30s",
"time_zone": "Asia/Seoul",
"min_doc_count": 1
}
}
},
"stored_fields": [
"*"
],
"script_fields": {},
"docvalue_fields": [
{
"field": "createDate",
"format": "date_time"
},
{
"field": "firstReleaseDate",
"format": "date_time"
},
{
"field": "lastReleaseDate",
"format": "date_time"
},
{
"field": "releaseDate",
"format": "date_time"
},
{
"field": "updateDate",
"format": "date_time"
}
],
"query": {
"bool": {
"must": [
{
"range": {
"createDate": {
"format": "strict_date_optional_time",
"gte": "2021-05-28T05:52:47.808Z",
"lte": "2021-05-28T06:07:47.808Z"
}
}
}
],
"filter": [
{
"bool": {
"filter": [
{
"bool": {
"should": [
{
"match": {
"selfType": 0
}
}
],
"minimum_should_match": 1
}
},
{
"bool": {
"should": [
{
"match_phrase": {
"id": "20210423"
}
}
],
"minimum_should_match": 1
}
}
]
}
}
],
"should": [],
"must_not": []
}
},
"highlight": {
"pre_tags": [
"@kibana-highlighted-field@"
],
"post_tags": [
"@/kibana-highlighted-field@"
],
"fields": {
"*": {}
},
"fragment_size": 2147483647
}
}
이런식으로 뜬다.
"query": {
"bool": {
"must": [
{
"range": {
"createDate": {
"format": "strict_date_optional_time",
"gte": "2021-05-28T05:52:47.808Z",
"lte": "2021-05-28T06:07:47.808Z"
}
}
}
],
"filter": [
{
"bool": {
"filter": [
{
"bool": {
"should": [
{
"match": {
"selfType": 0
}
}
],
"minimum_should_match": 1
}
},
{
"bool": {
"should": [
{
"match_phrase": {
"id": "20210423"
}
}
],
"minimum_should_match": 1
}
}
]
}
}
],
"should": [],
"must_not": []
}
},
쿼리를 돌리기 위해 필요한 부분은 query 로 시작하는 부분이다.
update를 하면 결과값이 나오긴 하지만 수동으로 세부적으로 쿼리를 수정해보고 싶다면
왼쪽에 밑에서 세번째 아이콘을 누른 후 복사한 쿼리를 돌리면 결과값을 확인할 수 있다.
GET article_1/_search 라고 써져있는 부분은 엘라스틱의 인덱스 이름을 article_1 자리에 기입해 주면된다.
'Development > TIP' 카테고리의 다른 글
[InteliJ] import 제대로 안될 때 (0) | 2023.01.26 |
---|---|
[InteliJ] 검색 제대로 안될 때 (0) | 2022.04.14 |
[eclipse] 기본클래스를 찾거나 로드할 수 없습니다. (0) | 2022.04.11 |
JSON to JAVA class (0) | 2021.08.20 |
댓글
링크
최근에 올라온 글
- Total
- Today
- Yesterday