]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - includes/search/SearchIndexField.php
MediaWiki 1.30.2
[autoinstallsdev/mediawiki.git] / includes / search / SearchIndexField.php
1 <?php
2 /**
3  * Definition of a mapping for the search index field.
4  * @since 1.28
5  */
6 interface SearchIndexField {
7         /**
8          * Field types
9          */
10         const INDEX_TYPE_TEXT = 0;
11         const INDEX_TYPE_KEYWORD = 1;
12         const INDEX_TYPE_INTEGER = 2;
13         const INDEX_TYPE_NUMBER = 3;
14         const INDEX_TYPE_DATETIME = 4;
15         const INDEX_TYPE_NESTED = 5;
16         const INDEX_TYPE_BOOL = 6;
17
18         /**
19          * SHORT_TEXT is meant to be used with short text made of mostly ascii
20          * technical information. Generally a language agnostic analysis chain
21          * is used and aggressive splitting to increase recall.
22          * E.g suited for mime/type
23          */
24         const INDEX_TYPE_SHORT_TEXT = 7;
25
26         /**
27          * Generic field flags.
28          */
29         /**
30          * This field is case-insensitive.
31          */
32         const FLAG_CASEFOLD = 1;
33
34         /**
35          * This field contains secondary information, which is
36          * already present in other fields, but can be used for
37          * scoring.
38          */
39         const FLAG_SCORING = 2;
40
41         /**
42          * This field does not need highlight handling.
43          */
44         const FLAG_NO_HIGHLIGHT = 4;
45
46         /**
47          * Do not index this field, just store it.
48          */
49         const FLAG_NO_INDEX = 8;
50
51         /**
52          * Get mapping for specific search engine
53          * @param SearchEngine $engine
54          * @return array|null Null means this field does not map to anything
55          */
56         public function getMapping( SearchEngine $engine );
57
58         /**
59          * Set global flag for this field.
60          *
61          * @param int $flag Bit flag to set/unset
62          * @param bool $unset True if flag should be unset, false by default
63          * @return $this
64          */
65         public function setFlag( $flag, $unset = false );
66
67         /**
68          * Check if flag is set.
69          * @param int $flag
70          * @return int 0 if unset, !=0 if set
71          */
72         public function checkFlag( $flag );
73
74         /**
75          * Merge two field definitions if possible.
76          *
77          * @param SearchIndexField $that
78          * @return SearchIndexField|false New definition or false if not mergeable.
79          */
80         public function merge( SearchIndexField $that );
81
82         /**
83          * A list of search engine hints for this field.
84          * Hints are usually specific to a search engine implementation
85          * and allow to fine control how the search engine will handle this
86          * particular field.
87          *
88          * For example some search engine permits some optimizations
89          * at index time by ignoring an update if the updated value
90          * does not change by more than X% on a numeric value.
91          *
92          * @param SearchEngine $engine
93          * @return array an array of hints generally indexed by hint name. The type of
94          * values is search engine specific
95          * @since 1.30
96          */
97         public function getEngineHints( SearchEngine $engine );
98 }