You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
searchMatchessearchDictionaryType=0// For checking whether there are words in dictionary starting with something
163
+
searchStartingWithsearchDictionaryType=1// Find all words in dictionary starting with something
164
+
searchExactWordssearchDictionaryType=2// Find exact words in dictionary
165
+
)
166
+
159
167
// all - Search for words starting with the word
160
-
func (varnam*Varnam) searchDictionary(ctx context.Context, words []string, allbool) []searchDictionaryResult {
168
+
func (varnam*Varnam) searchDictionary(ctx context.Context, words []string, searchTypesearchDictionaryType) []searchDictionaryResult {
161
169
likes:=""
162
170
163
171
var (
@@ -184,11 +192,13 @@ func (varnam *Varnam) searchDictionary(ctx context.Context, words []string, all
184
192
// CC BY-SA 4.0 licensed
185
193
// https://stackoverflow.com/q/68610241/1372424
186
194
187
-
ifall {
188
-
query="WITH cte(match) AS (VALUES (?) "+likes+") SELECT c.match AS match, w.* FROM words_fts w INNER JOIN cte c ON w.word MATCH c.match || '*' AND learned_on > 0 ORDER BY weight DESC LIMIT ?"
query="WITH cte(match) AS (VALUES (?) "+likes+") SELECT c.match AS match, w.word AS word, MAX(w.weight), MAX(w.learned_on) FROM words_fts w INNER JOIN cte c ON w.word MATCH c.match || '*' GROUP BY c.match"
197
+
} elseifsearchType==searchStartingWith {
198
+
query="WITH cte(match) AS (VALUES (?) "+likes+") SELECT c.match AS match, w.* FROM words_fts w INNER JOIN cte c ON w.word MATCH c.match || '*' AND w.word != c.match ORDER BY weight DESC LIMIT ?"
0 commit comments