| 1 |
<?php |
| 2 |
/** |
| 3 |
* Elasticsearch mapping for users post ES 7.0 |
| 4 |
* |
| 5 |
* @since 3.0 |
| 6 |
* @package elasticpress |
| 7 |
*/ |
| 8 |
|
| 9 |
if ( ! defined( 'ABSPATH' ) ) { |
| 10 |
exit; // Exit if accessed directly. |
| 11 |
} |
| 12 |
|
| 13 |
return array( |
| 14 |
'settings' => array( |
| 15 |
/** |
| 16 |
* Filter number of Elasticsearch shards to use in indices |
| 17 |
* |
| 18 |
* @hook ep_default_index_number_of_shards |
| 19 |
* @param {int} $shards Number of shards |
| 20 |
* @return {int} New number |
| 21 |
*/ |
| 22 |
'index.number_of_shards' => apply_filters( 'ep_default_index_number_of_shards', 5 ), |
| 23 |
/** |
| 24 |
* Filter number of Elasticsearch replicas to use in indices |
| 25 |
* |
| 26 |
* @hook ep_default_index_number_of_replicas |
| 27 |
* @param {int} $replicas Number of replicas |
| 28 |
* @return {int} New number |
| 29 |
*/ |
| 30 |
'index.number_of_replicas' => apply_filters( 'ep_default_index_number_of_replicas', 1 ), |
| 31 |
/** |
| 32 |
* Filter Elasticsearch total field limit for users |
| 33 |
* |
| 34 |
* @hook ep_user_total_field_limit |
| 35 |
* @param {int} $number Number of fields |
| 36 |
* @return {int} New number |
| 37 |
*/ |
| 38 |
'index.mapping.total_fields.limit' => apply_filters( 'ep_user_total_field_limit', 5000 ), |
| 39 |
/** |
| 40 |
* Filter Elasticsearch maximum shingle difference |
| 41 |
* |
| 42 |
* @hook ep_max_shingle_diff |
| 43 |
* @param {int} $number Max difference |
| 44 |
* @return {int} New number |
| 45 |
*/ |
| 46 |
'index.max_shingle_diff' => apply_filters( 'ep_max_shingle_diff', 8 ), |
| 47 |
/** |
| 48 |
* Filter Elasticsearch max result window for users |
| 49 |
* |
| 50 |
* @hook ep_user_max_result_window |
| 51 |
* @param {int} $number Size of result window |
| 52 |
* @return {int} New number |
| 53 |
*/ |
| 54 |
'index.max_result_window' => apply_filters( 'ep_user_max_result_window', 1000000 ), |
| 55 |
/** |
| 56 |
* Filter whether Elasticsearch ignores malformed fields or not. |
| 57 |
* |
| 58 |
* @hook ep_ignore_malformed |
| 59 |
* @param {bool} $ignore True for ignore |
| 60 |
* @return {bool} New value |
| 61 |
*/ |
| 62 |
'index.mapping.ignore_malformed' => apply_filters( 'ep_ignore_malformed', true ), |
| 63 |
'analysis' => array( |
| 64 |
'analyzer' => array( |
| 65 |
'default' => array( |
| 66 |
'tokenizer' => 'standard', |
| 67 |
'filter' => array( 'ewp_word_delimiter', 'lowercase', 'stop', 'ewp_snowball' ), |
| 68 |
/** |
| 69 |
* Filter Elasticsearch default language in mapping |
| 70 |
* |
| 71 |
* @hook ep_analyzer_language |
| 72 |
* @param {string} $lang Default language |
| 73 |
* @param {string} $lang_context Language context |
| 74 |
* @return {string} New language |
| 75 |
*/ |
| 76 |
'language' => apply_filters( 'ep_analyzer_language', 'english', 'analyzer_default' ), |
| 77 |
), |
| 78 |
'shingle_analyzer' => array( |
| 79 |
'type' => 'custom', |
| 80 |
'tokenizer' => 'standard', |
| 81 |
'filter' => array( 'lowercase', 'shingle_filter' ), |
| 82 |
), |
| 83 |
'ewp_lowercase' => array( |
| 84 |
'type' => 'custom', |
| 85 |
'tokenizer' => 'keyword', |
| 86 |
'filter' => array( 'lowercase' ), |
| 87 |
), |
| 88 |
), |
| 89 |
'filter' => array( |
| 90 |
'shingle_filter' => array( |
| 91 |
'type' => 'shingle', |
| 92 |
'min_shingle_size' => 2, |
| 93 |
'max_shingle_size' => 5, |
| 94 |
), |
| 95 |
'ewp_word_delimiter' => array( |
| 96 |
'type' => 'word_delimiter_graph', |
| 97 |
'preserve_original' => true, |
| 98 |
), |
| 99 |
'ewp_snowball' => array( |
| 100 |
'type' => 'snowball', |
| 101 |
/** |
| 102 |
* Filter Elasticsearch default language in mapping |
| 103 |
* |
| 104 |
* @hook ep_analyzer_language |
| 105 |
* @param {string} $lang Default language |
| 106 |
* @param {string} $lang_context Language context |
| 107 |
* @return {string} New language |
| 108 |
*/ |
| 109 |
'language' => apply_filters( 'ep_analyzer_language', 'english', 'filter_ewp_snowball' ), |
| 110 |
), |
| 111 |
'edge_ngram' => array( |
| 112 |
'side' => 'front', |
| 113 |
'max_gram' => 10, |
| 114 |
'min_gram' => 3, |
| 115 |
'type' => 'edge_ngram', |
| 116 |
), |
| 117 |
), |
| 118 |
'normalizer' => array( |
| 119 |
'lowerasciinormalizer' => array( |
| 120 |
'type' => 'custom', |
| 121 |
'filter' => array( 'lowercase', 'asciifolding' ), |
| 122 |
), |
| 123 |
), |
| 124 |
), |
| 125 |
), |
| 126 |
'mappings' => array( |
| 127 |
'date_detection' => false, |
| 128 |
'dynamic_templates' => array( |
| 129 |
array( |
| 130 |
'template_meta_types' => array( |
| 131 |
'path_match' => 'meta.*', |
| 132 |
'mapping' => array( |
| 133 |
'type' => 'object', |
| 134 |
'properties' => array( |
| 135 |
'value' => array( |
| 136 |
'type' => 'text', |
| 137 |
'fields' => array( |
| 138 |
'sortable' => array( |
| 139 |
'type' => 'keyword', |
| 140 |
'ignore_above' => 10922, |
| 141 |
'normalizer' => 'lowerasciinormalizer', |
| 142 |
), |
| 143 |
'raw' => array( |
| 144 |
'type' => 'keyword', |
| 145 |
'ignore_above' => 10922, |
| 146 |
), |
| 147 |
), |
| 148 |
), |
| 149 |
'raw' => array( /* Left for backwards compat */ |
| 150 |
'type' => 'keyword', |
| 151 |
'ignore_above' => 10922, |
| 152 |
), |
| 153 |
'long' => array( |
| 154 |
'type' => 'long', |
| 155 |
), |
| 156 |
'double' => array( |
| 157 |
'type' => 'double', |
| 158 |
), |
| 159 |
'boolean' => array( |
| 160 |
'type' => 'boolean', |
| 161 |
), |
| 162 |
'date' => array( |
| 163 |
'type' => 'date', |
| 164 |
'format' => 'yyyy-MM-dd', |
| 165 |
), |
| 166 |
'datetime' => array( |
| 167 |
'type' => 'date', |
| 168 |
'format' => 'yyyy-MM-dd HH:mm:ss', |
| 169 |
), |
| 170 |
'time' => array( |
| 171 |
'type' => 'date', |
| 172 |
'format' => 'HH:mm:ss', |
| 173 |
), |
| 174 |
), |
| 175 |
), |
| 176 |
), |
| 177 |
), |
| 178 |
array( |
| 179 |
'template_capabilities' => array( |
| 180 |
'path_match' => 'capabilities.*', |
| 181 |
'mapping' => array( |
| 182 |
'type' => 'object', |
| 183 |
'properties' => array( |
| 184 |
'roles' => array( |
| 185 |
'type' => 'keyword', |
| 186 |
), |
| 187 |
), |
| 188 |
), |
| 189 |
), |
| 190 |
), |
| 191 |
), |
| 192 |
'properties' => array( |
| 193 |
'ID' => array( |
| 194 |
'type' => 'long', |
| 195 |
), |
| 196 |
'user_registered' => array( |
| 197 |
'type' => 'date', |
| 198 |
'format' => 'yyyy-MM-dd HH:mm:ss', |
| 199 |
), |
| 200 |
'user_nicename' => array( |
| 201 |
'type' => 'text', |
| 202 |
'fields' => array( |
| 203 |
'user_nicename' => array( |
| 204 |
'type' => 'text', |
| 205 |
), |
| 206 |
'raw' => array( |
| 207 |
'type' => 'keyword', |
| 208 |
'ignore_above' => 10922, |
| 209 |
), |
| 210 |
), |
| 211 |
), |
| 212 |
'user_login' => array( |
| 213 |
'type' => 'text', |
| 214 |
'fields' => array( |
| 215 |
'user_login' => array( |
| 216 |
'type' => 'text', |
| 217 |
), |
| 218 |
'raw' => array( |
| 219 |
'type' => 'keyword', |
| 220 |
'ignore_above' => 10922, |
| 221 |
), |
| 222 |
), |
| 223 |
), |
| 224 |
'display_name' => array( |
| 225 |
'type' => 'text', |
| 226 |
'fields' => array( |
| 227 |
'raw' => array( |
| 228 |
'type' => 'keyword', |
| 229 |
'ignore_above' => 10922, |
| 230 |
), |
| 231 |
'sortable' => array( |
| 232 |
'type' => 'keyword', |
| 233 |
'normalizer' => 'lowerasciinormalizer', |
| 234 |
), |
| 235 |
), |
| 236 |
), |
| 237 |
'user_email' => array( |
| 238 |
'type' => 'text', |
| 239 |
'fields' => array( |
| 240 |
'user_email' => array( |
| 241 |
'type' => 'text', |
| 242 |
), |
| 243 |
'raw' => array( |
| 244 |
'type' => 'keyword', |
| 245 |
'ignore_above' => 10922, |
| 246 |
), |
| 247 |
), |
| 248 |
), |
| 249 |
'capabilities' => array( |
| 250 |
'type' => 'object', |
| 251 |
), |
| 252 |
'user_url' => array( |
| 253 |
'type' => 'text', |
| 254 |
'fields' => array( |
| 255 |
'user_url' => array( |
| 256 |
'type' => 'text', |
| 257 |
), |
| 258 |
'raw' => array( |
| 259 |
'type' => 'keyword', |
| 260 |
'ignore_above' => 10922, |
| 261 |
), |
| 262 |
), |
| 263 |
), |
| 264 |
'status' => array( |
| 265 |
'type' => 'long', |
| 266 |
), |
| 267 |
'spam' => array( |
| 268 |
'type' => 'long', |
| 269 |
), |
| 270 |
'deleted' => array( |
| 271 |
'type' => 'long', |
| 272 |
), |
| 273 |
'meta' => array( |
| 274 |
'type' => 'object', |
| 275 |
), |
| 276 |
), |
| 277 |
), |
| 278 |
); |
| 279 |
|