forked from algolia/algoliasearch-client-go
/
types_synonyms.go
68 lines (57 loc) · 1.67 KB
/
types_synonyms.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package algoliasearch
const (
AltCorrection1 string = "altCorrection1"
AltCorrection2 string = "altCorrection2"
)
type SearchSynonymsRes struct {
Hits []Synonym `json:"hits"`
NbHits int `json:"nbHits"`
}
type Synonym struct {
// Common fields
HighlightResult Map `json:"_highlightResult,omitempty"`
ObjectID string `json:"objectID"`
Type string `json:"type"`
// Alternative correction synonym's fields
Corrections []string `json:"corrections,omitempty"`
Word string `json:"word,omitempty"`
// One way synonym's fields
Input string `json:"input,omitempty"`
Synonyms []string `json:"synonyms,omitempty"`
// Placeholder synonym's fields
Placeholder string `json:"placeholder,omitempty"`
Replacements []string `json:"replacements,omitempty"`
// Simple synonym's field (shared with `oneWaySynonym`)
// Synonyms []string `json:"synonyms"`
}
func NewAltCorrectionSynonym(objectID string, corrections []string, word string, t string) Synonym {
return Synonym{
ObjectID: objectID,
Type: t,
Corrections: corrections,
Word: word,
}
}
func NewOneWaySynonym(objectID string, input string, synonyms []string) Synonym {
return Synonym{
ObjectID: objectID,
Type: "oneWaySynonym",
Input: input,
Synonyms: synonyms,
}
}
func NewPlaceholderSynonym(objectID string, placeholder string, replacements []string) Synonym {
return Synonym{
ObjectID: objectID,
Type: "placeholder",
Placeholder: placeholder,
Replacements: replacements,
}
}
func NewSynonym(objectID string, synonyms []string) Synonym {
return Synonym{
ObjectID: objectID,
Type: "synonym",
Synonyms: synonyms,
}
}