Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / search / SearchIndexField.php
blob37eba3003c3487cb1678dcbbabb1f5fa70a9ea38
1 <?php
2 /**
3 * Definition of a mapping for the search index field.
5 * Must not be implemented directly by extensions, extend SearchIndexFieldDefinition instead.
7 * @stable to type
8 * @since 1.28
9 */
10 interface SearchIndexField {
12 * Field types
14 /**
15 * TEXT fields are suitable for natural language and may be subject to
16 * analysis such as stemming.
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/
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.
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';
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
40 public const INDEX_TYPE_SHORT_TEXT = 'short_text';
42 /**
43 * Generic field flags.
45 /**
46 * This field is case-insensitive.
48 public const FLAG_CASEFOLD = 1;
50 /**
51 * This field contains secondary information, which is
52 * already present in other fields, but can be used for
53 * scoring.
55 public const FLAG_SCORING = 2;
57 /**
58 * This field does not need highlight handling.
60 public const FLAG_NO_HIGHLIGHT = 4;
62 /**
63 * Do not index this field, just store it.
65 public const FLAG_NO_INDEX = 8;
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
72 public function getMapping( SearchEngine $engine );
74 /**
75 * Set global flag for this field.
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
81 public function setFlag( $flag, $unset = false );
83 /**
84 * Check if flag is set.
85 * @param int $flag
86 * @return int 0 if unset, !=0 if set
88 public function checkFlag( $flag );
90 /**
91 * Merge two field definitions if possible.
93 * @param SearchIndexField $that
94 * @return SearchIndexField|false New definition or false if not mergeable.
96 public function merge( SearchIndexField $that );
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.
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.
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
113 public function getEngineHints( SearchEngine $engine );