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