CwpSolrIndex::init()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 17
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace CWP\Search\Solr;
4
5
use CWP\Search\CwpSearchIndex;
6
use SilverStripe\CMS\Model\SiteTree;
7
8
/**
9
 * Default search index
10
 */
11
class CwpSolrIndex extends CwpSearchIndex
12
{
13
    public function init()
14
    {
15
        $this->addClass(SiteTree::class);
16
17
        // By default, we only add text fields that are 'visible' to users (where the content is directly visible on
18
        // the website), along with the 'meta' fields that are commonly used to boost / refine search results
19
        $this->addFulltextField('Title');
20
        $this->addFulltextField('MenuTitle');
21
        $this->addFulltextField('Content');
22
        $this->addFulltextField('MetaDescription');
23
        $this->addFulltextField('ExtraMeta');
24
25
        // Adds 'ShowInSearch' boolean field to Solr document so we can later ensure that only documents included in
26
        // search are returned by Solr.
27
        $this->addFilterField('ShowInSearch');
28
29
        parent::init();
30
    }
31
}
32