diff options
Diffstat (limited to 'system/db/content.go')
-rw-r--r-- | system/db/content.go | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/system/db/content.go b/system/db/content.go index 7667831..a29ef20 100644 --- a/system/db/content.go +++ b/system/db/content.go @@ -121,9 +121,8 @@ func update(ns, id string, data url.Values, existingContent *[]byte) (int, error return 0, err } - // add data to search index target := fmt.Sprintf("%s:%s", ns, id) - err = Search[ns].Index(target, string(j)) + err = UpdateSearchIndex(target, string(j)) if err != nil { return 0, err } @@ -135,7 +134,7 @@ func mergeData(ns string, data url.Values, existingContent []byte) ([]byte, erro var j []byte t, ok := item.Types[ns] if !ok { - return nil, fmt.Errorf("namespace type not found:", ns) + return nil, fmt.Errorf("Namespace type not found: %s", ns) } // Unmarsal the existing values @@ -247,9 +246,8 @@ func insert(ns string, data url.Values) (int, error) { return 0, err } - // add data to search index target := fmt.Sprintf("%s:%s", ns, cid) - err = Search[ns].Index(target, string(j)) + err = UpdateSearchIndex(target, string(j)) if err != nil { return 0, err } @@ -313,6 +311,15 @@ func DeleteContent(target string) error { return err } + // delete indexed data from search index + if !strings.Contains(ns, "__") { + target = fmt.Sprintf("%s:%s", ns, id) + err = DeleteSearchIndex(target) + if err != nil { + return err + } + } + // exception to typical "run in goroutine" pattern: // we want to have an updated admin view as soon as this is deleted, so // in some cases, the delete and redirect is faster than the sort, |