summaryrefslogtreecommitdiff
path: root/system/item
diff options
context:
space:
mode:
authorSteve Manuel <nilslice@gmail.com>2017-04-11 02:09:28 -0700
committerSteve Manuel <nilslice@gmail.com>2017-04-11 02:09:28 -0700
commit39ed91df81073489b485fae9a437fdb74954c40b (patch)
treed4d6edf11c85002dd38cca0f758bc7b47c3a89d6 /system/item
parent31ba833f6cf0ac7bce42e8b9b8b44a3020e140b9 (diff)
parent6c340440a24b6b0b309c0ef3554297e758823f7d (diff)
Merge branch 'throttle-sort'
Diffstat (limited to 'system/item')
-rw-r--r--system/item/item.go11
-rw-r--r--system/item/types.go3
2 files changed, 14 insertions, 0 deletions
diff --git a/system/item/item.go b/system/item/item.go
index 99d70a8..4750ef5 100644
--- a/system/item/item.go
+++ b/system/item/item.go
@@ -7,6 +7,8 @@ import (
"strings"
"unicode"
+ "github.com/blevesearch/bleve"
+ "github.com/blevesearch/bleve/mapping"
uuid "github.com/satori/go.uuid"
"golang.org/x/text/transform"
"golang.org/x/text/unicode/norm"
@@ -208,6 +210,15 @@ func (i Item) AfterReject(res http.ResponseWriter, req *http.Request) error {
return nil
}
+// SearchMapping returns a default implementation of a Bleve IndexMappingImpl
+// partially implements db.Searchable
+func (i Item) SearchMapping() (*mapping.IndexMappingImpl, error) {
+ mapping := bleve.NewIndexMapping()
+ mapping.StoreDynamic = false
+
+ return mapping, nil
+}
+
// Slug returns a URL friendly string from the title of a post item
func Slug(i Identifiable) (string, error) {
// get the name of the post item
diff --git a/system/item/types.go b/system/item/types.go
index bcae58a..dbf13af 100644
--- a/system/item/types.go
+++ b/system/item/types.go
@@ -26,6 +26,9 @@ var (
// if requested by a valid admin or user
ErrAllowHiddenItem = errors.New(`Allow hidden item`)
+ // ErrNoSearchMapping can be used to tell the system not to create an index mapping
+ ErrNoSearchMapping = errors.New(`No search mapping for item`)
+
// Types is a map used to reference a type name to its actual Editable type
// mainly for lookups in /admin route based utilities
Types map[string]func() interface{}