diff --git a/code/search/SearchIndex.php b/code/search/SearchIndex.php index 1892302..15fe830 100644 --- a/code/search/SearchIndex.php +++ b/code/search/SearchIndex.php @@ -187,6 +187,10 @@ abstract class SearchIndex extends ViewableData { throw new Exception('Can\'t add class to Index after fields have already been added'); } + if (!DataObject::has_own_table($class)) { + throw new InvalidArgumentException('Can\'t add classes which don\'t have data tables (no $db or $has_one set on the class)'); + } + $options = array_merge(array( 'include_children' => true ), $options);