| 1 |
<?php |
| 2 |
/** |
| 3 |
* Elasticsearch mapping for ES 5.2 |
| 4 |
* |
| 5 |
* @since 2.4 |
| 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 posts |
| 33 |
* |
| 34 |
* @hook ep_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_total_field_limit', 5000 ), |
| 39 |
/** |
| 40 |
* Filter whether Elasticsearch ignores malformed fields or not. |
| 41 |
* |
| 42 |
* @hook ep_ignore_malformed |
| 43 |
* @param {bool} $ignore True for ignore |
| 44 |
* @return {bool} New value |
| 45 |
*/ |
| 46 |
'index.mapping.ignore_malformed' => apply_filters( 'ep_ignore_malformed', true ), |
| 47 |
/** |
| 48 |
* Filter Elasticsearch max result window for posts |
| 49 |
* |
| 50 |
* @hook ep_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_max_result_window', 1000000 ), |
| 55 |
/** |
| 56 |
* Filter Elasticsearch maximum shingle difference |
| 57 |
* |
| 58 |
* @hook ep_max_shingle_diff |
| 59 |
* @param {int} $number Max difference |
| 60 |
* @return {int} New number |
| 61 |
*/ |
| 62 |
'index.max_shingle_diff' => apply_filters( 'ep_max_shingle_diff', 8 ), |
| 63 |
'analysis' => array( |
| 64 |
'analyzer' => array( |
| 65 |
'default' => array( |
| 66 |
'tokenizer' => 'standard', |
| 67 |
/** |
| 68 |
* Filter Elasticsearch default analyzer's filters |
| 69 |
* |
| 70 |
* @since 3.6.2 |
| 71 |
* @hook ep_default_analyzer_filters |
| 72 |
* @param {array<string>} $filters Default filters |
| 73 |
* @return {array<string>} New filters |
| 74 |
*/ |
| 75 |
'filter' => apply_filters( 'ep_default_analyzer_filters', array( 'ewp_word_delimiter', 'lowercase', 'stop', 'ewp_snowball' ) ), |
| 76 |
'char_filter' => array( 'html_strip' ), |
| 77 |
/** |
| 78 |
* Filter Elasticsearch default language in mapping |
| 79 |
* |
| 80 |
* @hook ep_analyzer_language |
| 81 |
* @param {string} $lang Default language |
| 82 |
* @param {string} $lang_context Language context |
| 83 |
* @return {string} New language |
| 84 |
*/ |
| 85 |
'language' => apply_filters( 'ep_analyzer_language', 'english', 'analyzer_default' ), |
| 86 |
), |
| 87 |
'shingle_analyzer' => array( |
| 88 |
'type' => 'custom', |
| 89 |
'tokenizer' => 'standard', |
| 90 |
'filter' => array( 'lowercase', 'shingle_filter' ), |
| 91 |
), |
| 92 |
'ewp_lowercase' => array( |
| 93 |
'type' => 'custom', |
| 94 |
'tokenizer' => 'keyword', |
| 95 |
'filter' => array( 'lowercase' ), |
| 96 |
), |
| 97 |
), |
| 98 |
'filter' => array( |
| 99 |
'shingle_filter' => array( |
| 100 |
'type' => 'shingle', |
| 101 |
'min_shingle_size' => 2, |
| 102 |
'max_shingle_size' => 5, |
| 103 |
), |
| 104 |
'ewp_word_delimiter' => array( |
| 105 |
'type' => 'word_delimiter_graph', |
| 106 |
'preserve_original' => true, |
| 107 |
), |
| 108 |
'ewp_snowball' => array( |
| 109 |
'type' => 'snowball', |
| 110 |
/** |
| 111 |
* Filter Elasticsearch default language in mapping |
| 112 |
* |
| 113 |
* @hook ep_analyzer_language |
| 114 |
* @param {string} $lang Default language |
| 115 |
* @param {string} $lang_context Language context |
| 116 |
* @return {string} New language |
| 117 |
*/ |
| 118 |
'language' => apply_filters( 'ep_analyzer_language', 'english', 'filter_ewp_snowball' ), |
| 119 |
), |
| 120 |
'edge_ngram' => array( |
| 121 |
'side' => 'front', |
| 122 |
'max_gram' => 10, |
| 123 |
'min_gram' => 3, |
| 124 |
'type' => 'edge_ngram', |
| 125 |
), |
| 126 |
), |
| 127 |
'normalizer' => array( |
| 128 |
'lowerasciinormalizer' => array( |
| 129 |
'type' => 'custom', |
| 130 |
'filter' => array( 'lowercase', 'asciifolding' ), |
| 131 |
), |
| 132 |
), |
| 133 |
), |
| 134 |
), |
| 135 |
'mappings' => array( |
| 136 |
'_meta' => array( |
| 137 |
'mapping_version' => '7-0.php', |
| 138 |
), |
| 139 |
'date_detection' => false, |
| 140 |
'dynamic_templates' => array( |
| 141 |
array( |
| 142 |
'template_meta' => array( |
| 143 |
'path_match' => 'post_meta.*', |
| 144 |
'mapping' => array( |
| 145 |
'type' => 'text', |
| 146 |
'fields' => array( |
| 147 |
'{name}' => array( |
| 148 |
'type' => 'text', |
| 149 |
), |
| 150 |
'raw' => array( |
| 151 |
'type' => 'keyword', |
| 152 |
'ignore_above' => 10922, |
| 153 |
), |
| 154 |
), |
| 155 |
), |
| 156 |
), |
| 157 |
), |
| 158 |
array( |
| 159 |
'template_meta_types' => array( |
| 160 |
'path_match' => 'meta.*', |
| 161 |
'mapping' => array( |
| 162 |
'type' => 'object', |
| 163 |
'properties' => array( |
| 164 |
'value' => array( |
| 165 |
'type' => 'text', |
| 166 |
'fields' => array( |
| 167 |
'sortable' => array( |
| 168 |
'type' => 'keyword', |
| 169 |
'ignore_above' => 10922, |
| 170 |
'normalizer' => 'lowerasciinormalizer', |
| 171 |
), |
| 172 |
'raw' => array( |
| 173 |
'type' => 'keyword', |
| 174 |
'ignore_above' => 10922, |
| 175 |
), |
| 176 |
), |
| 177 |
), |
| 178 |
'raw' => array( /* Left for backwards compat */ |
| 179 |
'type' => 'keyword', |
| 180 |
'ignore_above' => 10922, |
| 181 |
), |
| 182 |
'long' => array( |
| 183 |
'type' => 'long', |
| 184 |
), |
| 185 |
'double' => array( |
| 186 |
'type' => 'double', |
| 187 |
), |
| 188 |
'boolean' => array( |
| 189 |
'type' => 'boolean', |
| 190 |
), |
| 191 |
'date' => array( |
| 192 |
'type' => 'date', |
| 193 |
'format' => 'yyyy-MM-dd', |
| 194 |
), |
| 195 |
'datetime' => array( |
| 196 |
'type' => 'date', |
| 197 |
'format' => 'yyyy-MM-dd HH:mm:ss', |
| 198 |
), |
| 199 |
'time' => array( |
| 200 |
'type' => 'date', |
| 201 |
'format' => 'HH:mm:ss', |
| 202 |
), |
| 203 |
), |
| 204 |
), |
| 205 |
), |
| 206 |
), |
| 207 |
array( |
| 208 |
'template_terms' => array( |
| 209 |
'path_match' => 'terms.*', |
| 210 |
'mapping' => array( |
| 211 |
'type' => 'object', |
| 212 |
'properties' => array( |
| 213 |
'name' => array( |
| 214 |
'type' => 'text', |
| 215 |
'fields' => array( |
| 216 |
'raw' => array( |
| 217 |
'type' => 'keyword', |
| 218 |
), |
| 219 |
'sortable' => array( |
| 220 |
'type' => 'keyword', |
| 221 |
'normalizer' => 'lowerasciinormalizer', |
| 222 |
), |
| 223 |
), |
| 224 |
), |
| 225 |
'term_id' => array( |
| 226 |
'type' => 'long', |
| 227 |
), |
| 228 |
'term_taxonomy_id' => array( |
| 229 |
'type' => 'long', |
| 230 |
), |
| 231 |
'parent' => array( |
| 232 |
'type' => 'long', |
| 233 |
), |
| 234 |
'slug' => array( |
| 235 |
'type' => 'keyword', |
| 236 |
), |
| 237 |
'facet' => array( |
| 238 |
'type' => 'keyword', |
| 239 |
), |
| 240 |
'term_order' => array( |
| 241 |
'type' => 'long', |
| 242 |
), |
| 243 |
), |
| 244 |
), |
| 245 |
), |
| 246 |
), |
| 247 |
array( |
| 248 |
'term_suggest' => array( |
| 249 |
'path_match' => 'term_suggest_*', |
| 250 |
'mapping' => array( |
| 251 |
'type' => 'completion', |
| 252 |
'analyzer' => 'default', |
| 253 |
), |
| 254 |
), |
| 255 |
), |
| 256 |
), |
| 257 |
'properties' => array( |
| 258 |
'post_id' => array( |
| 259 |
'type' => 'long', |
| 260 |
), |
| 261 |
'ID' => array( |
| 262 |
'type' => 'long', |
| 263 |
), |
| 264 |
'post_author' => array( |
| 265 |
'type' => 'object', |
| 266 |
'properties' => array( |
| 267 |
'display_name' => array( |
| 268 |
'type' => 'text', |
| 269 |
'fields' => array( |
| 270 |
'raw' => array( |
| 271 |
'type' => 'keyword', |
| 272 |
), |
| 273 |
'sortable' => array( |
| 274 |
'type' => 'keyword', |
| 275 |
'normalizer' => 'lowerasciinormalizer', |
| 276 |
), |
| 277 |
), |
| 278 |
), |
| 279 |
'login' => array( |
| 280 |
'type' => 'text', |
| 281 |
'fields' => array( |
| 282 |
'raw' => array( |
| 283 |
'type' => 'keyword', |
| 284 |
), |
| 285 |
'sortable' => array( |
| 286 |
'type' => 'keyword', |
| 287 |
'normalizer' => 'lowerasciinormalizer', |
| 288 |
), |
| 289 |
), |
| 290 |
), |
| 291 |
'id' => array( |
| 292 |
'type' => 'long', |
| 293 |
), |
| 294 |
'raw' => array( |
| 295 |
'type' => 'keyword', |
| 296 |
), |
| 297 |
), |
| 298 |
), |
| 299 |
'post_date' => array( |
| 300 |
'type' => 'date', |
| 301 |
'format' => 'yyyy-MM-dd HH:mm:ss', |
| 302 |
), |
| 303 |
'post_date_gmt' => array( |
| 304 |
'type' => 'date', |
| 305 |
'format' => 'yyyy-MM-dd HH:mm:ss', |
| 306 |
), |
| 307 |
'post_title' => array( |
| 308 |
'type' => 'text', |
| 309 |
'fields' => array( |
| 310 |
'post_title' => array( |
| 311 |
'type' => 'text', |
| 312 |
'analyzer' => 'standard', |
| 313 |
), |
| 314 |
'raw' => array( |
| 315 |
'type' => 'keyword', |
| 316 |
'ignore_above' => 10922, |
| 317 |
), |
| 318 |
'sortable' => array( |
| 319 |
'type' => 'keyword', |
| 320 |
'ignore_above' => 10922, |
| 321 |
'normalizer' => 'lowerasciinormalizer', |
| 322 |
), |
| 323 |
), |
| 324 |
), |
| 325 |
'post_excerpt' => array( |
| 326 |
'type' => 'text', |
| 327 |
), |
| 328 |
'post_password' => array( |
| 329 |
'type' => 'text', |
| 330 |
), |
| 331 |
'post_content' => array( |
| 332 |
'type' => 'text', |
| 333 |
), |
| 334 |
'post_content_filtered' => array( |
| 335 |
'type' => 'text', |
| 336 |
), |
| 337 |
'post_status' => array( |
| 338 |
'type' => 'keyword', |
| 339 |
), |
| 340 |
'post_name' => array( |
| 341 |
'type' => 'text', |
| 342 |
'fields' => array( |
| 343 |
'post_name' => array( |
| 344 |
'type' => 'text', |
| 345 |
), |
| 346 |
'raw' => array( |
| 347 |
'type' => 'keyword', |
| 348 |
'ignore_above' => 10922, |
| 349 |
), |
| 350 |
), |
| 351 |
), |
| 352 |
'post_modified' => array( |
| 353 |
'type' => 'date', |
| 354 |
'format' => 'yyyy-MM-dd HH:mm:ss', |
| 355 |
), |
| 356 |
'post_modified_gmt' => array( |
| 357 |
'type' => 'date', |
| 358 |
'format' => 'yyyy-MM-dd HH:mm:ss', |
| 359 |
), |
| 360 |
'post_parent' => array( |
| 361 |
'type' => 'long', |
| 362 |
), |
| 363 |
'post_type' => array( |
| 364 |
'type' => 'text', |
| 365 |
'fields' => array( |
| 366 |
'post_type' => array( |
| 367 |
'type' => 'text', |
| 368 |
), |
| 369 |
'raw' => array( |
| 370 |
'type' => 'keyword', |
| 371 |
), |
| 372 |
), |
| 373 |
), |
| 374 |
'post_mime_type' => array( |
| 375 |
'type' => 'keyword', |
| 376 |
), |
| 377 |
'permalink' => array( |
| 378 |
'type' => 'keyword', |
| 379 |
), |
| 380 |
'guid' => array( |
| 381 |
'type' => 'keyword', |
| 382 |
), |
| 383 |
'terms' => array( |
| 384 |
'type' => 'object', |
| 385 |
), |
| 386 |
'post_meta' => array( |
| 387 |
'type' => 'object', |
| 388 |
), |
| 389 |
'meta' => array( |
| 390 |
'type' => 'object', |
| 391 |
), |
| 392 |
'date_terms' => array( |
| 393 |
'type' => 'object', |
| 394 |
'properties' => array( |
| 395 |
'year' => array( // 4 digit year (e.g. 2011). |
| 396 |
'type' => 'integer', |
| 397 |
), |
| 398 |
'month' => array( // Month number (from 1 to 12) alternate name 'monthnum'. |
| 399 |
'type' => 'integer', |
| 400 |
), |
| 401 |
'm' => array( // YearMonth (For e.g.: 201307). |
| 402 |
'type' => 'integer', |
| 403 |
), |
| 404 |
'week' => array( // Week of the year (from 0 to 53) alternate name 'w'. |
| 405 |
'type' => 'integer', |
| 406 |
), |
| 407 |
'day' => array( // Day of the month (from 1 to 31). |
| 408 |
'type' => 'integer', |
| 409 |
), |
| 410 |
'dayofweek' => array( // Accepts numbers 1-7 (1 is Sunday). |
| 411 |
'type' => 'integer', |
| 412 |
), |
| 413 |
'dayofweek_iso' => array( // Accepts numbers 1-7 (1 is Monday). |
| 414 |
'type' => 'integer', |
| 415 |
), |
| 416 |
'dayofyear' => array( // Accepts numbers 1-366. |
| 417 |
'type' => 'integer', |
| 418 |
), |
| 419 |
'hour' => array( // Hour (from 0 to 23). |
| 420 |
'type' => 'integer', |
| 421 |
), |
| 422 |
'minute' => array( // Minute (from 0 to 59). |
| 423 |
'type' => 'integer', |
| 424 |
), |
| 425 |
'second' => array( // Second (0 to 59). |
| 426 |
'type' => 'integer', |
| 427 |
), |
| 428 |
), |
| 429 |
), |
| 430 |
'thumbnail' => array( |
| 431 |
'type' => 'object', |
| 432 |
'properties' => array( |
| 433 |
'ID' => array( |
| 434 |
'type' => 'long', |
| 435 |
), |
| 436 |
'src' => array( |
| 437 |
'type' => 'text', |
| 438 |
), |
| 439 |
'width' => array( |
| 440 |
'type' => 'integer', |
| 441 |
), |
| 442 |
'height' => array( |
| 443 |
'type' => 'integer', |
| 444 |
), |
| 445 |
'alt' => array( |
| 446 |
'type' => 'text', |
| 447 |
), |
| 448 |
), |
| 449 |
), |
| 450 |
), |
| 451 |
), |
| 452 |
); |
| 453 |
|