3 * Definition of a mapping for the search index field.
6 interface SearchIndexField
{
11 * TEXT fields are suitable for natural language and may be subject to
12 * analysis such as stemming.
15 * https://wikimediafoundation.org/2018/08/07/anatomy-search-token-affection/
16 * https://wikimediafoundation.org/2018/09/13/anatomy-search-variation-under-nature/
18 const INDEX_TYPE_TEXT
= 0;
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.
23 const INDEX_TYPE_KEYWORD
= 1;
24 const INDEX_TYPE_INTEGER
= 2;
25 const INDEX_TYPE_NUMBER
= 3;
26 const INDEX_TYPE_DATETIME
= 4;
27 const INDEX_TYPE_NESTED
= 5;
28 const INDEX_TYPE_BOOL
= 6;
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
36 const INDEX_TYPE_SHORT_TEXT
= 7;
39 * Generic field flags.
42 * This field is case-insensitive.
44 const FLAG_CASEFOLD
= 1;
47 * This field contains secondary information, which is
48 * already present in other fields, but can be used for
51 const FLAG_SCORING
= 2;
54 * This field does not need highlight handling.
56 const FLAG_NO_HIGHLIGHT
= 4;
59 * Do not index this field, just store it.
61 const FLAG_NO_INDEX
= 8;
64 * Get mapping for specific search engine
65 * @param SearchEngine $engine
66 * @return array|null Null means this field does not map to anything
68 public function getMapping( SearchEngine
$engine );
71 * Set global flag for this field.
73 * @param int $flag Bit flag to set/unset
74 * @param bool $unset True if flag should be unset, false by default
77 public function setFlag( $flag, $unset = false );
80 * Check if flag is set.
82 * @return int 0 if unset, !=0 if set
84 public function checkFlag( $flag );
87 * Merge two field definitions if possible.
89 * @param SearchIndexField $that
90 * @return SearchIndexField|false New definition or false if not mergeable.
92 public function merge( SearchIndexField
$that );
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
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.
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
109 public function getEngineHints( SearchEngine
$engine );