Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
LexemeKeywordField | |
0.00% |
0 / 9 |
|
0.00% |
0 / 3 |
30 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getMapping | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |||
getMappingField | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | namespace Wikibase\Lexeme\Search\Elastic; |
3 | |
4 | use CirrusSearch\CirrusSearch; |
5 | use CirrusSearch\Search\KeywordIndexField; |
6 | use SearchEngine; |
7 | use SearchIndexField; |
8 | use SearchIndexFieldDefinition; |
9 | use Wikibase\Repo\Search\Fields\WikibaseIndexField; |
10 | |
11 | /** |
12 | * Keyword field for lexeme implementation |
13 | */ |
14 | abstract class LexemeKeywordField extends SearchIndexFieldDefinition implements WikibaseIndexField { |
15 | |
16 | public const NAME = "unknown_field"; |
17 | |
18 | public function __construct() { |
19 | parent::__construct( static::NAME, \SearchIndexField::INDEX_TYPE_KEYWORD ); |
20 | } |
21 | |
22 | /** |
23 | * @param SearchEngine $engine |
24 | * |
25 | * @return array |
26 | */ |
27 | public function getMapping( SearchEngine $engine ) { |
28 | // Since we need a specially tuned field, we can not use |
29 | // standard search engine types. |
30 | if ( !( $engine instanceof CirrusSearch ) ) { |
31 | // For now only Cirrus/Elastic is supported |
32 | return []; |
33 | } |
34 | |
35 | $keyword = new KeywordIndexField( $this->getName(), $this->getIndexType(), $engine->getConfig() ); |
36 | $keyword->setFlag( self::FLAG_CASEFOLD ); |
37 | return $keyword->getMapping( $engine ); |
38 | } |
39 | |
40 | /** |
41 | * Produce specific field mapping |
42 | * |
43 | * @param SearchEngine $engine |
44 | * @param string $name |
45 | * |
46 | * @return SearchIndexField|null |
47 | */ |
48 | public function getMappingField( SearchEngine $engine, $name ) { |
49 | if ( !( $engine instanceof CirrusSearch ) ) { |
50 | // For now only Cirrus/Elastic is supported |
51 | return null; |
52 | } |
53 | return $this; |
54 | } |
55 | |
56 | } |