package eapi

type M map[string]interface{}

// SearchModel 基本搜索模型
type SearchModel struct {
	Took     int  `json:"took"`
	TimedOut bool `json:"timed_out"`
	Shards   struct {
		Total      int `json:"total"`
		Successful int `json:"successful"`
		Skipped    int `json:"skipped"`
		Failed     int `json:"failed"`
	} `json:"_shards"`
	Hits struct {
		Total struct {
			Value    int    `json:"value"`
			Relation string `json:"relation"`
		} `json:"total"`
		MaxScore interface{} `json:"max_score"`
		Hits     []struct {
			Index  string      `json:"_index"`
			Id     string      `json:"_id"`
			Score  interface{} `json:"_score"`
			Source interface{} `json:"_source"`
			Sort   []int       `json:"sort"`
		} `json:"hits"`
	} `json:"hits"`
}

// CountModel 统计行数
type CountModel struct {
	Count  int64 `json:"count"`
	Shards struct {
		Total      int `json:"total"`
		Successful int `json:"successful"`
		Skipped    int `json:"skipped"`
		Failed     int `json:"failed"`
	} `json:"_shards"`
}

// CardinalityModel 去重统计行数
type CardinalityModel struct {
	Took     int  `json:"took"`
	TimedOut bool `json:"timed_out"`
	Shards   struct {
		Total      int `json:"total"`
		Successful int `json:"successful"`
		Skipped    int `json:"skipped"`
		Failed     int `json:"failed"`
	} `json:"_shards"`
	Hits struct {
		Total struct {
			Value    int    `json:"value"`
			Relation string `json:"relation"`
		} `json:"total"`
		MaxScore interface{}   `json:"max_score"`
		Hits     []interface{} `json:"hits"`
	} `json:"hits"`
	Aggregations struct {
		Count struct {
			Value int64 `json:"value"`
		} `json:"count"`
	} `json:"aggregations"`
}

// FirstModel 第一条数据
type FirstModel struct {
	Took     int  `json:"took"`
	TimedOut bool `json:"timed_out"`
	Shards   struct {
		Total      int `json:"total"`
		Successful int `json:"successful"`
		Skipped    int `json:"skipped"`
		Failed     int `json:"failed"`
	} `json:"_shards"`
	Hits struct {
		Total struct {
			Value    int    `json:"value"`
			Relation string `json:"relation"`
		} `json:"total"`
		MaxScore interface{} `json:"max_score"`
		Hits     []struct {
			Index  string      `json:"_index"`
			Id     string      `json:"_id"`
			Score  interface{} `json:"_score"`
			Source interface{} `json:"_source"`
			Sort   []int       `json:"sort"`
		} `json:"hits"`
	} `json:"hits"`
}

// LastModel 最后一条数据
type LastModel struct {
	Took     int  `json:"took"`
	TimedOut bool `json:"timed_out"`
	Shards   struct {
		Total      int `json:"total"`
		Successful int `json:"successful"`
		Skipped    int `json:"skipped"`
		Failed     int `json:"failed"`
	} `json:"_shards"`
	Hits struct {
		Total struct {
			Value    int    `json:"value"`
			Relation string `json:"relation"`
		} `json:"total"`
		MaxScore interface{} `json:"max_score"`
		Hits     []struct {
			Index  string      `json:"_index"`
			Id     string      `json:"_id"`
			Score  interface{} `json:"_score"`
			Source interface{} `json:"_source"`
			Sort   []int       `json:"sort"`
		} `json:"hits"`
	} `json:"hits"`
}

// TopListModel 排行榜
type TopListModel struct {
	Took     int  `json:"took"`
	TimedOut bool `json:"timed_out"`
	Shards   struct {
		Total      int `json:"total"`
		Successful int `json:"successful"`
		Skipped    int `json:"skipped"`
		Failed     int `json:"failed"`
	} `json:"_shards"`
	Hits struct {
		Total struct {
			Value    int    `json:"value"`
			Relation string `json:"relation"`
		} `json:"total"`
		MaxScore float64 `json:"max_score"`
		Hits     []struct {
			Index string  `json:"_index"`
			Id    string  `json:"_id"`
			Score float64 `json:"_score"`
		} `json:"hits"`
	} `json:"hits"`
	Aggregations struct {
		Vals struct {
			DocCountErrorUpperBound int         `json:"doc_count_error_upper_bound"`
			SumOtherDocCount        int         `json:"sum_other_doc_count"`
			Buckets                 []TopBucket `json:"buckets"`
		} `json:"vals"`
	} `json:"aggregations"`
}

// TopBucket 排行榜桶
type TopBucket struct {
	Key      int64 `json:"key"`
	DocCount int64 `json:"doc_count"`
}

// TopSumScoreListModel 聚合字段的排行榜
type TopSumScoreListModel struct {
	Took     int  `json:"took"`
	TimedOut bool `json:"timed_out"`
	Shards   struct {
		Total      int `json:"total"`
		Successful int `json:"successful"`
		Skipped    int `json:"skipped"`
		Failed     int `json:"failed"`
	} `json:"_shards"`
	Hits struct {
		Total struct {
			Value    int    `json:"value"`
			Relation string `json:"relation"`
		} `json:"total"`
		MaxScore interface{}   `json:"max_score"`
		Hits     []interface{} `json:"hits"`
	} `json:"hits"`
	Aggregations struct {
		Vals struct {
			DocCountErrorUpperBound int                 `json:"doc_count_error_upper_bound"`
			SumOtherDocCount        int                 `json:"sum_other_doc_count"`
			Buckets                 []TopSumScoreBucket `json:"buckets"`
		} `json:"vals"`
	} `json:"aggregations"`
}

// TopSumScoreBucket 排行榜桶
type TopSumScoreBucket struct {
	Key      int64 `json:"key"`
	DocCount int64 `json:"doc_count"`
	SumScore struct {
		Value float64 `json:"value"`
	} `json:"sum_score"`
}
