Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
1 | <?php |
2 | /** |
3 | * Definition of a mapping for the search index field. |
4 | * |
5 | * Must not be implemented directly by extensions, extend SearchIndexFieldDefinition instead. |
6 | * |
7 | * @stable to type |
8 | * @since 1.28 |
9 | */ |
10 | interface SearchIndexField { |
11 | /* |
12 | * Field types |
13 | */ |
14 | /** |
15 | * TEXT fields are suitable for natural language and may be subject to |
16 | * analysis such as stemming. |
17 | * |
18 | * Read more: |
19 | * https://wikimediafoundation.org/2018/08/07/anatomy-search-token-affection/ |
20 | * https://wikimediafoundation.org/2018/09/13/anatomy-search-variation-under-nature/ |
21 | */ |
22 | public const INDEX_TYPE_TEXT = 'text'; |
23 | /** |
24 | * KEYWORD fields are indexed without any processing, so are appropriate |
25 | * for e.g. URLs. The content will often consist of a single token. |
26 | */ |
27 | public const INDEX_TYPE_KEYWORD = 'keyword'; |
28 | public const INDEX_TYPE_INTEGER = 'integer'; |
29 | public const INDEX_TYPE_NUMBER = 'number'; |
30 | public const INDEX_TYPE_DATETIME = 'datetime'; |
31 | public const INDEX_TYPE_NESTED = 'nested'; |
32 | public const INDEX_TYPE_BOOL = 'bool'; |
33 | |
34 | /** |
35 | * SHORT_TEXT is meant to be used with short text made of mostly ascii |
36 | * technical information. Generally a language agnostic analysis chain |
37 | * is used and aggressive splitting to increase recall. |
38 | * E.g suited for mime/type |
39 | */ |
40 | public const INDEX_TYPE_SHORT_TEXT = 'short_text'; |
41 | |
42 | /** |
43 | * Generic field flags. |
44 | */ |
45 | /** |
46 | * This field is case-insensitive. |
47 | */ |
48 | public const FLAG_CASEFOLD = 1; |
49 | |
50 | /** |
51 | * This field contains secondary information, which is |
52 | * already present in other fields, but can be used for |
53 | * scoring. |
54 | */ |
55 | public const FLAG_SCORING = 2; |
56 | |
57 | /** |
58 | * This field does not need highlight handling. |
59 | */ |
60 | public const FLAG_NO_HIGHLIGHT = 4; |
61 | |
62 | /** |
63 | * Do not index this field, just store it. |
64 | */ |
65 | public const FLAG_NO_INDEX = 8; |
66 | |
67 | /** |
68 | * Get mapping for specific search engine |
69 | * @param SearchEngine $engine |
70 | * @return array|null Null means this field does not map to anything |
71 | */ |
72 | public function getMapping( SearchEngine $engine ); |
73 | |
74 | /** |
75 | * Set global flag for this field. |
76 | * |
77 | * @param int $flag Bit flag to set/unset |
78 | * @param bool $unset True if flag should be unset, false by default |
79 | * @return $this |
80 | */ |
81 | public function setFlag( $flag, $unset = false ); |
82 | |
83 | /** |
84 | * Check if flag is set. |
85 | * @param int $flag |
86 | * @return int 0 if unset, !=0 if set |
87 | */ |
88 | public function checkFlag( $flag ); |
89 | |
90 | /** |
91 | * Merge two field definitions if possible. |
92 | * |
93 | * @param SearchIndexField $that |
94 | * @return SearchIndexField|false New definition or false if not mergeable. |
95 | */ |
96 | public function merge( SearchIndexField $that ); |
97 | |
98 | /** |
99 | * A list of search engine hints for this field. |
100 | * Hints are usually specific to a search engine implementation |
101 | * and allow to fine control how the search engine will handle this |
102 | * particular field. |
103 | * |
104 | * For example some search engine permits some optimizations |
105 | * at index time by ignoring an update if the updated value |
106 | * does not change by more than X% on a numeric value. |
107 | * |
108 | * @param SearchEngine $engine |
109 | * @return array an array of hints generally indexed by hint name. The type of |
110 | * values is search engine specific |
111 | * @since 1.30 |
112 | */ |
113 | public function getEngineHints( SearchEngine $engine ); |
114 | } |