summaryrefslogtreecommitdiff
path: root/system/db/content.go
diff options
context:
space:
mode:
authorSteve Manuel <nilslice@gmail.com>2017-04-06 17:53:34 -0700
committerSteve Manuel <nilslice@gmail.com>2017-04-06 17:53:34 -0700
commitba201f640c883d5ed2f3e1f68daff3a7ee4c8b9f (patch)
treef3640ff2fabd1b45b62a0f045ba19289ebb5625c /system/db/content.go
parentbf15dcfa48a46991f3c6d90f50aa491b5a15d5df (diff)
renaming and add Delete operation for search index
Diffstat (limited to 'system/db/content.go')
-rw-r--r--system/db/content.go17
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,