From 98ed6842653115afa1d84bb9529a4cb960a32276 Mon Sep 17 00:00:00 2001 From: realTristan Date: Sun, 4 Jun 2023 10:53:54 -0400 Subject: [PATCH] cleaned up --- nocache/insert.go | 2 +- nocache/withft.go | 8 +++----- withft.go | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/nocache/insert.go b/nocache/insert.go index 2ce1c43..65e999e 100644 --- a/nocache/insert.go +++ b/nocache/insert.go @@ -19,7 +19,7 @@ func (ft *FullText) insert(data []map[string]any, minWordLength int) error { strvNormal string strv string ) - if _strv := ftFromMap(value); len(_strv) > 0 { + if _strv := WFTGetValueFromMap(value); len(_strv) > 0 { strv = _strv strvNormal = _strv } else { diff --git a/nocache/withft.go b/nocache/withft.go index 12976ca..d841d3f 100644 --- a/nocache/withft.go +++ b/nocache/withft.go @@ -1,7 +1,7 @@ package nocache // Get the full-text value from a map -func ftFromMap(value any) string { +func WFTGetValueFromMap(value any) string { if _, ok := value.(map[string]any); !ok { return "" } @@ -14,10 +14,8 @@ func ftFromMap(value any) string { // Verify that the map has the correct keys if ft, ok := v["$hermes.full_text"]; ok { - if ft, ok := ft.(bool); ok { - if !ft { - return "" - } else if v, ok := v["$hermes.value"]; ok { + if ft, ok := ft.(bool); ok && ft { + if v, ok := v["$hermes.value"]; ok { if v, ok := v.(string); ok { return v } diff --git a/withft.go b/withft.go index 1525f0b..4a9823c 100644 --- a/withft.go +++ b/withft.go @@ -33,7 +33,7 @@ func WFTGetValue(value any) string { return "" } -// ftFromMap is a function that gets the full-text value from a map. +// WFTGetValueFromMap is a function that gets the full-text value from a map. // // Parameters: // - value: any representing the value to get the full-text value from.