3 * Definition of a mapping for the search index field.
5 * Must not be implemented directly by extensions, extend SearchIndexFieldDefinition instead.
10 interface SearchIndexField
{
15 * TEXT fields are suitable for natural language and may be subject to
16 * analysis such as stemming.
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';
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';
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';
43 * Generic field flags.
46 * This field is case-insensitive.
48 public const FLAG_CASEFOLD
= 1;
51 * This field contains secondary information, which is
52 * already present in other fields, but can be used for
55 public const FLAG_SCORING
= 2;
58 * This field does not need highlight handling.
60 public const FLAG_NO_HIGHLIGHT
= 4;
63 * Do not index this field, just store it.
65 public const FLAG_NO_INDEX
= 8;
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 );
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
81 public function setFlag( $flag, $unset = false );
84 * Check if flag is set.
86 * @return int 0 if unset, !=0 if set
88 public function checkFlag( $flag );
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 );
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
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
113 public function getEngineHints( SearchEngine
$engine );