plasticstudio / search
Search engine for Silverstripe websites - forked from jaedb/search
Installs: 2 460
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 6
Type:silverstripe-vendormodule
pkg:composer/plasticstudio/search
Requires
- silverstripe/cms: ^4 || ^5
 - silverstripe/framework: ^4 || ^5
 - silverstripe/vendor-plugin: ^1 || ^2
 
- dev-master
 - 3.x-dev
 - 1.0.23
 - 1.0.22
 - 1.0.21
 - 1.0.20
 - 1.0.19
 - 1.0.18
 - 1.0.17
 - 1.0.16
 - 1.0.15
 - 1.0.14
 - 1.0.13
 - 1.0.12
 - 1.0.11
 - 1.0.10
 - 1.0.9
 - 1.0.8
 - 1.0.7
 - 1.0.6
 - 1.0.5
 - 1.0.4
 - 1.0.3
 - 1.0.2
 - 1.0.1
 - 1.0.0
 - dev-feature/priority
 - dev-bugfix/php-8.1-errors
 - dev-fix/php8.1-str_replace
 - dev-feature/elemental-search-test
 - dev-fix/multiple_manymany_filters
 
This package is auto-updated.
Last update: 2025-10-21 23:30:36 UTC
README
The built-in SilverStripe search form is a very simple search engine. This plugin takes SQL-based searching to the next level, without requiring the implementation of a full-blown search engine like Solr or Elastic Search. It is designed to bring data-oriented filters on top of the simple text search functionality.
Requirements
- SilverStripe 4
 
Usage
- Create a 
SearchPageinstance (typically at the root of your website). This page only is used to display results, so please refrain from creating multiple instances. - Configure your website's 
_config/config.yml(or add_config/search.yml) to define search parameters. - Run 
dev/buildto instansiate your new configuration (this will also automatically create an instance ofSearchPageif one does not exist). - To overwrite the default 
SearchPagetmeplate, add a template file to your application:templates/PlasticStudio/Search/Layout/SearchPage.ss 
Upgrading from jaedb/search
Ensure you review the search config and update it to match the example config in this repo. Key changes:
Table: 'SiteTree_Live'->Table: 'Page_Live'- Add 
JoinTables: ['SiteTree_Live'] 
Elemental
- Elemental search is included
 - On page or Element save, all content from all Elements is saved to a field called 
ElementalSearchContenton sitetree. - Simply include 
'SiteTree_Live.ElementalSearchContent'to the list of page columns - Currently there is no way to exclude individual elements from being included.
 - Run IndexPageContentForSearchTask to index element content
 
Configuration
types: associative list of types to searchLabel: front-end field labelTable: the object's primary table (note_Livesuffix for versioned objects)ClassName: full ClassNameClassNameShort: namespaced ClassNameFilters: a list of filters to apply pre-search (maps toDataList->Filter(key => value))Columns: columns to search for query string matches (formatTable.Column)
filters: associative list of filter optionsStructure: defines the filter's relational structure (must be one ofdb,has_oneormany_many)Label: front-end field labelTable: relational subject's tableColumn: column to filter onOperator: SQL filter operator (ie>,<,=)JoinTables: associative list of relationship mappings (use thekeyfrom thetypesarray)Table: relational join tableColumn: column to join by
sorts: associative list of sort options. These are used to popoulate a "Sort by" dropdown field in the Advanced Search Form. Sort order of search results will default to the top item in this list.Label: front-end field labelSort: SQL sort string
search_form_placeholder_text: Change search input field placeholder text (defaults to "Keywords")submit_button_text: Text to use on search form submit button (defaults to "Search")
TODO: defaults: Default attributes or settings, as opposed to those submitted through the search form.
Indexing Dataobjects
The search checks canView permissions for Dataobjects before indexing, so you likely need to add:
public function canView($member = null) { return true; }
Example configuration
---
Name: search
Before:
    - '#site'
---
PlasticStudio\Search\SearchPageController:
  types:
    docs:
      Label: 'Documents'
      Table: 'File_Live'
      ClassName: 'SilverStripe\Assets\File'
      ClassNameShort: 'File'
      Filters:
        File_Live.ShowInSearch: '1'
        File_Live.ClassName:  '''Silverstripe\\Assets\\File''' # You need to TRIPLE-ESCAPE in order to pass this as a string to the query
      Columns: ['File_Live.Title','File_Live.Description','File_Live.Name']
    pages:
      Label: 'Pages'
      ClassName: 'Page'
      ClassNameShort: 'Page'
      Table: 'Page_Live'
      Filters: 
        SiteTree_Live.ShowInSearch: '1'
      JoinTables: ['SiteTree_Live']
      Columns: ['SiteTree_Live.Title','SiteTree_Live.MenuTitle','SiteTree_Live.Content', 'SiteTree_Live.ElementalSearchContent']
  filters:
    updated_before:
      Structure: 'db'
      Label: 'Updated before'
      Column: 'LastEdited'
      Operator: '<'
    updated_after:
      Structure: 'db'
      Label: 'Updated after'
      Column: 'LastEdited'
      Operator: '>'
    tags:
      Structure: 'many_many'
      Label: 'Tags'
      ClassName: 'Tag'
      Table: 'Tag'
      JoinTables:
        docs: 
          Table: 'File_Tags'
          Column: 'FileID'
        pages: 
          Table: 'Page_Tags'
          Column: 'PageID'
      authors:
        Structure: 'many_many'
        Label: 'Authors'
        ClassName: 'Member'
        Table: 'Member'
        JoinTables:
          pages: 
            Table: 'Page_Authors'
            Column: 'PageID'
  sorts:
    title_asc:
      Label: 'Title (A-Z)'
      Sort: 'Title ASC'
    title_desc:
      Label: 'Title (Z-A)'
      Sort: 'Title DESC'
    published_asc:
      Label: 'Publish date (newest first)'
      Sort: 'DatePublished DESC'
    published_desc:
      Label: 'Publish date (oldest first)'
      Sort: 'DatePublished ASC'
  search_form_placeholder_text: 'Keywords'
  submit_button_text: 'Go'
  ## TODO:
  ## defaults:
    ## sort: 'Title ASC'