diff options
Diffstat (limited to 'system/item')
-rw-r--r-- | system/item/item.go | 17 | ||||
-rw-r--r-- | system/item/types.go | 3 |
2 files changed, 20 insertions, 0 deletions
diff --git a/system/item/item.go b/system/item/item.go index 99d70a8..8f392ca 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,21 @@ 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 +} + +// IndexContent determines if a type should be indexed for searching +// partially implements db.Searchable +func (i Item) IndexContent() bool { + return false +} + // 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{} |