github.com/bosssauce/ponzu@v0.11.1-0.20200102001432-9bc41b703131/docs/src/Interfaces/Search.md (about)

     1  title: Search Package Interfaces
     2  
     3  Ponzu provides a set of interfaces from the `system/search` package to enable and customize full-text search access to content in your system. **Search is not enabled by default**, and must be enabled per Content type individually.
     4  
     5  ## Interfaces
     6  
     7  ### [search.Searchable](https://godoc.org/github.com/ponzu-cms/ponzu/system/search#Searchable)
     8  Searchable determines how content is indexed and whether the system should index the content when it is created and updated or be removed from the index when content is deleted.
     9      
    10  !!! warning ""
    11      Search is **disabled** for all Content items by default. Each Content item that should be indexed and searchable must implement the `search.Searchable` interface.
    12  
    13  ##### Method Set
    14  
    15  ```go
    16  type Searchable interface {
    17      SearchMapping() (*mapping.IndexMappingImpl, error)
    18      IndexContent() bool
    19  }
    20  ```
    21  
    22  By default, Ponzu sets up the [Bleve's](http://blevesearch.com) "default mapping", which is typically what you want for most content-based systems. This can be overridden by implementing your own `SearchMapping() (*mapping.IndexMappingImpl, error)` method on your Content type. 
    23  
    24  This way, all you need to do to get full-text search is to add the `IndexContent() bool` method to each Content type you want search enabled. Return `true` from this method to enable search. 
    25  
    26  
    27  ##### Example
    28  ```go
    29  // ...
    30  
    31  type Song struct {
    32      item.Item
    33  
    34      Name string `json:"name"`
    35      // ...
    36  }
    37  
    38  func (s *Song) IndexContent() bool {
    39      return true
    40  }
    41  ```
    42  
    43  !!! tip "Indexing Existing Content"
    44      If you previously had search disabled and had already added content to your system, you will need to re-index old content items in your CMS. Otherwise, they will not show up in search queries.. This requires you to manually open each item and click 'Save'. This could be scripted and Ponzu _might_ ship with a re-indexing function at some point in the fututre.