-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.go
47 lines (40 loc) · 1.35 KB
/
models.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
41
42
43
44
45
46
47
package search
import (
"context"
"gopkg.in/olivere/elastic.v6"
)
type Intent struct {
Type string `json:"type"`
Language string `json:"language"`
Value interface{} `json:"value,omitempty"`
}
type Query struct {
Term string `json:"term,omitempty"`
ExactTerms []string `json:"exact_terms,omitempty"`
Filters map[string][]string `json:"filters,omitempty"`
LanguageOrder []string `json:"language_order,omitempty"`
Deb bool `json:"deb,omitempty"`
Intents []Intent `json:"intents,omitempty"`
}
type QueryResult struct {
SearchResult *elastic.SearchResult `json:"search_result,omitempty"`
Intents []Intent `json:"intents,omitempty"`
}
type Engine interface {
GetSuggestions(ctx context.Context, query Query) (interface{}, error)
DoSearch(ctx context.Context, query Query, from int, size int, preference string) (interface{}, error)
}
type SearchRequestOptions struct {
resultTypes []string
index string
query Query
sortBy string
from int
size int
preference string
useHighlight bool
// Following field comes to solve elastic bug with highlight.
// Just removed the analyzed fields and uses only standard fields
// for highlighting. Only happens with intents.
partialHighlight bool
}