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"
          }
        }
      }
    }
  }
}

猜你喜欢

转载自blog.csdn.net/yiyiholic/article/details/83108662