Merge pull request #8 from silverstripe-big-o/pull/docs-types
Docs about custom types
This commit is contained in:
commit
83badd9215
19
docs/Solr.md
19
docs/Solr.md
|
@ -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.
|
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.
|
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
|
## Debugging
|
||||||
|
|
||||||
### Using the web admin interface
|
### 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
|
// Wrong: Filter will ignore all empty field values
|
||||||
$myQuery->filter(<field>, new SearchQuery_Range('*', <date>));
|
$myQuery->filter(<field>, new SearchQuery_Range('*', <date>));
|
||||||
// Better: Exclude the opposite range
|
// Better: Exclude the opposite range
|
||||||
$myQuery->exclude(<field>, new SearchQuery_Range(<date>, '*'));
|
$myQuery->exclude(<field>, new SearchQuery_Range(<date>, '*'));
|
||||||
|
|
Loading…
Reference in New Issue