본문 바로가기

카테고리 없음

elasticsearch multiple condition

 

curl -X POST "localhost:9200/_search?pretty" -H 'Content-Type: application/json' -d'
{
  "query": {
    "bool" : {
      "must" : {
        "term" : { "user" : "kimchy" }
      },
      "filter": {
        "term" : { "tag" : "tech" }
      },
      "must_not" : {
        "range" : {
          "age" : { "gte" : 10, "lte" : 20 }
        }
      },
      "should" : [
        { "term" : { "tag" : "wow" } },
        { "term" : { "tag" : "elasticsearch" } }
      ],
      "minimum_should_match" : 1,
      "boost" : 1.0
    }
  }
}
'

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html

 

Boolean query | Elasticsearch Reference [7.6] | Elastic

A query that matches documents matching boolean combinations of other queries. The bool query maps to Lucene BooleanQuery. It is built using one or more boolean clauses, each clause with a typed occurrence. The occurrence types are: Occur Description must

www.elastic.co

여러 조건 한번에 써야할때. 위 꼴로.

괄호 한개 닫히고 안닫히고 쉼표 찍히고 안찍히고 때문에 짜증남