diff --git a/code/solr/SolrIndex.php b/code/solr/SolrIndex.php
index bea3b1d..0a72114 100644
--- a/code/solr/SolrIndex.php
+++ b/code/solr/SolrIndex.php
@@ -46,6 +46,14 @@ abstract class SolrIndex extends SearchIndex {
* @config
*/
private static $default_field = '_text';
+
+ /**
+ * List of copy fields all fulltext fields should be copied into.
+ * This will fallback to default_field if not specified
+ *
+ * @var array
+ */
+ private static $copy_fields = array();
/**
* @return String Absolute path to the folder containing
@@ -104,6 +112,22 @@ abstract class SolrIndex extends SearchIndex {
return $this->config()->default_field;
}
+ /**
+ * Get list of fields each text field should be copied into.
+ * This will fallback to the default field if omitted.
+ *
+ * @return array
+ */
+ protected function getCopyDestinations() {
+ $copyFields = $this->config()->copy_fields;
+ if($copyFields) {
+ return $copyFields;
+ }
+ // Fallback to default field
+ $df = $this->getDefaultField();
+ return array($df);
+ }
+
public function getFieldDefinitions() {
$xml = array();
$stored = $this->getStoredDefault();
@@ -365,14 +389,22 @@ abstract class SolrIndex extends SearchIndex {
);
}
- function getCopyFieldDefinitions() {
+ /**
+ * Generate XML for copy field definitions
+ *
+ * @return string
+ */
+ public function getCopyFieldDefinitions() {
$xml = array();
- $df = $this->getDefaultField();
- foreach ($this->fulltextFields as $name => $field) {
- $xml[] = "";
+ // Default copy fields
+ foreach($this->getCopyDestinations() as $copyTo) {
+ foreach ($this->fulltextFields as $name => $field) {
+ $xml[] = "";
+ }
}
+ // Explicit copy fields
foreach ($this->copyFields as $source => $fields) {
foreach($fields as $fieldAttrs) {
$xml[] = $this->toXmlTag('copyField', $fieldAttrs);
diff --git a/conf/solr/4/templates/types.ss b/conf/solr/4/templates/types.ss
index 135c8ac..c4081b8 100644
--- a/conf/solr/4/templates/types.ss
+++ b/conf/solr/4/templates/types.ss
@@ -203,6 +203,17 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/en/Solr.md b/docs/en/Solr.md
index eeef086..de66329 100644
--- a/docs/en/Solr.md
+++ b/docs/en/Solr.md
@@ -183,7 +183,7 @@ This can be fixed by aggregating spell checking data in a separate
$xml = parent::getFieldDefinitions();
$xml .= "\n\n\t\t";
- $xml .= "\n\t\t";
+ $xml .= "\n\t\t";
return $xml;
}