BuildTokens tokenizes a value, creating strings that can be used to create index keys.
(val interface{}, t Tokenizer)
| 108 | // BuildTokens tokenizes a value, creating strings that can be used to create |
| 109 | // index keys. |
| 110 | func BuildTokens(val interface{}, t Tokenizer) ([]string, error) { |
| 111 | tokens, err := t.Tokens(val) |
| 112 | if err != nil { |
| 113 | return nil, err |
| 114 | } |
| 115 | id := t.Identifier() |
| 116 | for i := range tokens { |
| 117 | tokens[i] = encodeToken(tokens[i], id) |
| 118 | } |
| 119 | return tokens, nil |
| 120 | } |
| 121 | |
| 122 | func BuildNGramQueryTokens(val interface{}, t NGramTokenizer) ([]string, error) { |
| 123 | tokens, err := t.QueryTokens(val) |