2014-09-21 02:07:58 +02:00
|
|
|
summary: Provide your users with advanced search functionality.
|
|
|
|
|
2011-02-07 07:48:44 +01:00
|
|
|
# Search
|
|
|
|
|
|
|
|
## Searching for Pages (and Files)
|
|
|
|
|
|
|
|
Fulltext search for page content (and other attributes like "Title" or "MetaTags") can be easily added to SilverStripe.
|
2014-09-28 05:59:48 +02:00
|
|
|
See [Tutorial: Site Search](/tutorials/site_search) for details.
|
2011-02-07 07:48:44 +01:00
|
|
|
|
2011-10-29 02:46:09 +02:00
|
|
|
## Searching for DataObjects
|
2011-02-07 07:48:44 +01:00
|
|
|
|
2014-09-21 02:07:58 +02:00
|
|
|
The `[api:SearchContext]` class provides a good base implementation that you can hook into your own controllers.
|
2014-09-28 05:59:48 +02:00
|
|
|
A working implementation of searchable DataObjects can be seen in the [ModelAdmin](../customising_the_cms/modeladmin) class.
|
2011-03-08 22:05:51 +01:00
|
|
|
|
2014-09-28 05:59:48 +02:00
|
|
|
[SearchContext](/searchcontext) goes into more detail about setting up a default search form for `[api:DataObject]`s.
|
2011-02-07 07:48:44 +01:00
|
|
|
|
2014-09-28 05:59:48 +02:00
|
|
|
## Fulltext search on DataObjects
|
2011-10-29 02:46:09 +02:00
|
|
|
|
2014-09-28 05:59:48 +02:00
|
|
|
The `[api:MySQLDatabase]` class now defaults to creating tables using the InnoDB storage engine. As Fulltext search in
|
|
|
|
MySQL requires the MyISAM storage engine, any DataObject you wish to use with Fulltext search must be changed to use
|
|
|
|
MyISAM storage engine.
|
2011-10-29 02:46:09 +02:00
|
|
|
|
|
|
|
You can do so by adding this static variable to your class definition:
|
2011-10-29 02:48:22 +02:00
|
|
|
|
2011-10-29 02:46:09 +02:00
|
|
|
:::php
|
2013-03-21 19:48:54 +01:00
|
|
|
private static $create_table_options = array(
|
2011-10-29 02:46:09 +02:00
|
|
|
'MySQLDatabase' => 'ENGINE=MyISAM'
|
|
|
|
);
|
|
|
|
|
2011-02-07 07:48:44 +01:00
|
|
|
## Searching for Documents
|
|
|
|
|
2014-09-28 05:59:48 +02:00
|
|
|
SilverStripe does not have a built-in method to search through file content (e.g. in PDF or DOC format). You can either
|
|
|
|
extract any textual file content into the `[File](api:File)->Content` property, or use a dedicated search service like
|
|
|
|
the [Full module](http://silverstripe.org/sphinx-module).
|
2011-02-07 07:48:44 +01:00
|
|
|
|
|
|
|
## Related
|
|
|
|
|
2012-06-28 11:43:56 +02:00
|
|
|
* [ModelAdmin](/reference/modeladmin)
|
2012-06-04 10:21:29 +02:00
|
|
|
* [RestfulServer module](https://github.com/silverstripe/silverstripe-restfulserver)
|
2011-02-07 07:48:44 +01:00
|
|
|
* [Tutorial: Site Search](/tutorials/4-site-search)
|
2011-03-08 22:05:51 +01:00
|
|
|
* [SearchContext](/reference/searchcontext)
|
2011-02-07 07:48:44 +01:00
|
|
|
* [genericviews module](http://silverstripe.org/generic-views-module)
|
|
|
|
* [sphinx module](http://silverstripe.org/sphinx-module)
|
|
|
|
* [lucene module](http://silverstripe.org/lucene-module)
|