feat:完成首页搜索功能
This commit is contained in:
@ -73,21 +73,21 @@ func Search(src interface{}, index string, params *SearchParams, page, pageSize
|
||||
}
|
||||
out := make([]interface{}, 0)
|
||||
|
||||
_type := reflect.TypeOf(src)
|
||||
_type := reflect.TypeOf(src).Elem()
|
||||
|
||||
for _, hit := range result.Hits.Hits {
|
||||
data := reflect.New(_type).Interface()
|
||||
_src := reflect.New(_type).Interface()
|
||||
|
||||
if err = json.Unmarshal(hit.Source, data); err != nil {
|
||||
if err = json.Unmarshal(hit.Source, _src); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out = append(out, data)
|
||||
out = append(out, _src)
|
||||
}
|
||||
return out, err
|
||||
}
|
||||
|
||||
// Delete 删除操作
|
||||
func Delete(index string) error {
|
||||
_, err := client.DeleteIndex(index).Do(context.Background())
|
||||
func Delete(index, id string) error {
|
||||
_, err := client.Delete().Index(index).Do(context.Background())
|
||||
return err
|
||||
}
|
||||
|
Reference in New Issue
Block a user