Skip to content

Instantly share code, notes, and snippets.

@wilr
Created May 14, 2019 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wilr/1e70c7ab8efba86174dd506832229c2c to your computer and use it in GitHub Desktop.
Save wilr/1e70c7ab8efba86174dd506832229c2c to your computer and use it in GitHub Desktop.
solr-issues-silverstripe
--- a/app/src/Search/CustomerSolrIndex.php
+++ b/app/src/Search/CustomerSolrIndex.php
@@ -9,10 +9,14 @@ use SilverStripe\Control\Director;
*/
class CustomerSolrIndex extends GazetteSolrIndex
{
+ private static $casting = [
+ 'FieldDefinitions' => 'HTMLFragment',
+ 'CopyFieldDefinitions' => 'HTMLFragment'
+ ];
@wilr
Copy link
Author

wilr commented May 14, 2019

While upgrading to SilverStripe 4 I found that my custom Solr indexes stopped working with the following error default search field '_text' not defined or not indexed.

Upon checking the schema.xml file - it would be in a mess e.g <field name="_spellcheckText" type="textSpellHtml" indexed="true" stored="false" multivalued="true"></field></field></field></field></field></field></field></field></field>.

The issue - I have overloaded getFieldDefinitions to modify the XML but it was being returned as a string object (SilverStripe 4 no longer assumes the parents function casting).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment