-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExampleResetSubjectsIndex.php
More file actions
105 lines (97 loc) · 3.7 KB
/
ExampleResetSubjectsIndex.php
File metadata and controls
105 lines (97 loc) · 3.7 KB
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
<?php
$basePath = getenv( 'MW_INSTALL_PATH' ) !== false ? getenv( 'MW_INSTALL_PATH' ) : __DIR__ . '/../../..';
require_once $basePath . '/maintenance/Maintenance.php';
class ExampleResetSubjectsIndex extends Maintenance {
private $keywords = array();
public function __construct() {
parent::__construct();
global $wgServer;
global $globalLog;
global $wgScriptPath;
}
public function execute() {
# Delete
$ch = new CurlTransfer(SUBJECTS_INDEX, NULL, NULL, "DELETE");
$ch->exec();
# Create
$options = '
{
"settings" : {
"index" : {
"number_of_shards" : 1,
"number_of_replicas" : 1
}
}
}
';
$ch = new CurlTransfer(SUBJECTS_INDEX, NULL, NULL, "PUT");
$ch->setPostFields($options);
$ch->exec();
# Mapping
$mapping = '
{
"subject": {
"properties": {
"subjectName": {
"type": "string",
"include_in_all": "true"
},
"subjectTitle": {
"type": "string"
},
"subjectTitleNA": {
"type": "string",
"store": "true",
"index": "not_analyzed",
"include_in_all": "true"
},
"subjectType": {
"type": "string",
"index": "not_analyzed"
},
"subjectLink": {
"type": "string",
"index": "not_analyzed"
},
"subjectProperties": {
"type": "nested",
"include_in_parent": "true",
"properties": {
"subjectPropertyName": {
"type": "string",
"index": "not_analyzed",
"include_in_all": "true"
},
"subjectPropertyValues": {
"type": "nested",
"properties": {
"subjectPropertyValue": {
"type": "string",
"store": "true",
"include_in_all": "true"
},
"subjectPropertyValueNA": {
"type": "string",
"store": "true",
"index": "not_analyzed",
"include_in_all": "true"
}
}
}
}
}
}
}
}
';
$ch = new CurlTransfer(SUBJECTS_INDEX, "subject", "_mapping", "PUT");
$ch->setPostFields($mapping);
try {
$response = json_decode($ch->exec(), true);
} catch(Exception $e) {
error_log($e->getTrace());
}
}
}
$maintClass = 'ExampleResetSubjectsIndex';
require_once RUN_MAINTENANCE_IF_MAIN;