Merge pull request #8 from silverstripe-big-o/pull/docs-types

Docs about custom types
This commit is contained in:
Hamish Friedlander 2012-11-01 14:29:15 -07:00
commit 83badd9215
1 changed files with 18 additions and 1 deletions

View File

@ -76,6 +76,23 @@ You can also copy the `thirdparty/`solr directory somewhere else,
just set the path value in `mysite/_config.php` to point to the new location.
And of course run `java -jar start.jar` from the new directory.
### Custom Types
Solr supports custom field type definitions which are written to its XML schema.
Many standard ones are already included in the default schema.
As the XML file is generated dynamically, we can add our own types
by overloading the template responsible for it: `types.ss`.
In the following example, we read out type definitions
from a new file `mysite/solr/templates/types.ss` instead:
<?php
class MyIndex extends SolrIndex {
function getTypes() {
return $this->renderWith(Director::baseFolder() . '/mysite/solr/templates/types.ss');
}
}
## Debugging
### Using the web admin interface
@ -103,4 +120,4 @@ In order to query the field, reverse the search conditions and exclude the range
// Wrong: Filter will ignore all empty field values
$myQuery->filter(<field>, new SearchQuery_Range('*', <date>));
// Better: Exclude the opposite range
$myQuery->exclude(<field>, new SearchQuery_Range(<date>, '*'));
$myQuery->exclude(<field>, new SearchQuery_Range(<date>, '*'));