반응형

 

Query DSL Elasticsearch REST API [
 POST
 ,HEADER : { Content-Type : application/json }
 ,BODY: {raw: }
]
RDB
match_all {
  "query": {
    "match_all":{}
  }
}
select * from table
match {
  "query": {
    "match": { "필드명": "값" }
  }
}
select * from table
where 필드명= “값
bool,
match,
match_not
{
  "query": {
    "bool": {
      "must": [
        { "match": { "필드명": "" }
        }
      ],
      "must_not": [
        { "match": { "addressSiGunGu" : "강남구" }}
      ]
    }
  }
}
select * from table
where 필드명1 = “값1
and 필드명2 != “값2
range {
  "query": {
    "range": {
      "필드명": {
        "gte": "2021-03-07",
       
"lte": "2021-03-20",
       
"format": "yyyy-MM-dd"
      }
    }
  }
}
select * from table
where 필드명 between '값1' and '값2'
* range 관련 기본타입이 string인 경우 text field로 인식되어 정상적으로 검색이 안됨. 이런 경우 index로 바꿔주고 검색을 할 수 있음변환처리 아래 URL 참조
myhappyman.tistory.com/223?category=966871
sort
(몽고 db에서 string으로 처리되어 elasticSearch에서 text filed로 인식되면 sort가 불가능함)
{
  "sort": [
    { "필드명" : "desc" },
    "_score"
  ],
  "query": {
    "match_all":{}
  }
}
select * from table
order by 필드명 desc
regexp {
  "query": {
    "regexp":{
      "필드명": ".*값.*"
    }
  }
}
like문과 유사하지만 완전 다름
. : 모든 문자열을 뜻한다.  * : 0개 이상의 자리수를 갖는 문자열
0개 이상의 모든 문자열을 찾는 쿼리

 

 

단순 총 리스트의 개수 가져오기

GET /<target>/_count

반응형