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