1. 程式人生 > >elasticsearch學習之文件分組

elasticsearch學習之文件分組

GET tmdb/_search
{
  "size": 1, 
  "_source": " ", 
  "query": {
    "match": {
      "title": "star trek"
    }
  },
  "aggs": {
    "statuses": {
      "terms": {
        "field": "status.keyword"
      },
      "aggs": {
        "hits": {
          "top_hits": {
            "size": 1
      
          }
        }
      }
    }
  }
}
GET tmdb/_search
{
  "size": 1,
  "_source": "title", 
  "query": {
    "match": {
      "title": "star trek"
    }
  },
  "aggs": {
    "original_versions": {
      "terms": {
        "field": "original_language.keyword",
        "order": {
          "top_score": "desc"
        }
      },
      "aggs": {
        "hits": {
          "top_hits": {
            "size": 1
          }
        },
        "top_score":{
          "max": {
            "script": "_score"
          }
        }
      }
    }
  }
}