-
Notifications
You must be signed in to change notification settings - Fork 1
/
search.go
40 lines (30 loc) · 990 Bytes
/
search.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package search
import "github.com/webx-top/echo"
type Searcher interface {
Add(index string, primaryKey string, docs ...interface{}) error
Update(index string, primaryKey string, docs ...interface{}) error
Delete(index string, ids ...string) error
Flush() error
InitIndex(cfg *IndexConfig) error
Search(index string, keywords string, options *SearchRequest) (int64, []echo.H, error)
}
var DefaultSearch = &NopSearch{}
type NopSearch struct{}
func (n *NopSearch) Add(index string, primaryKey string, docs ...interface{}) error {
return nil
}
func (m *NopSearch) Update(index string, primaryKey string, docs ...interface{}) error {
return nil
}
func (m *NopSearch) Delete(index string, ids ...string) error {
return nil
}
func (m *NopSearch) InitIndex(cfg *IndexConfig) error {
return nil
}
func (n *NopSearch) Flush() error {
return nil
}
func (n *NopSearch) Search(index string, keywords string, options *SearchRequest) (int64, []echo.H, error) {
return 0, nil, nil
}