From 3c0b7479a0450e4008dd5f8c3bd9df44faa1d099 Mon Sep 17 00:00:00 2001 From: loveuer Date: Sun, 29 Dec 2024 23:22:30 -0800 Subject: [PATCH] feat: add es search res model --- internal/model/es.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 internal/model/es.go diff --git a/internal/model/es.go b/internal/model/es.go new file mode 100644 index 0000000..681357a --- /dev/null +++ b/internal/model/es.go @@ -0,0 +1,27 @@ +package model + +type ESSource[T any] struct { + DocId string `json:"_id"` + Index string `json:"_index"` + Content T `json:"_source"` + Sort []any `json:"sort"` +} + +type ESSearchResponse[T any] 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 []*ESSource[T] `json:"hits"` + } `json:"hits"` +}