-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy path4.php
90 lines (64 loc) · 1.57 KB
/
4.php
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
<?php
require_once 'vendor/autoload.php';
if($argv[1] == 1){
// define("XS_APP_ROOT", "./config");
$xs = new XS('demo');
$doc = $xs->search->search("项目");
print_r($doc);
print_r($xs->search->getConnString());
}
if($argv[1] == 2){
$xs = new XS('./config/demo2.ini');
$doc = $xs->search->search("项目");
print_r($doc);
}
if($argv[1] == 3){
$indexName = 'demo3';
$indexConfig = <<< EOF
project.name = $indexName
project.default_charset = utf-8
[pid]
type = id
[subject]
type = title
[message]
type = body
[chrono]
type = numeric
[author]
type = string
index = both
EOF;
$xs = new XS($indexConfig);
if($argv[2]){
$xs->index->clean();
$data = [
[
'pid'=>1,
'subject'=>'三号DEMO的,关于 xunsearch 的 DEMO 项目测试',
'message'=>'项目测试是一个很有意思的行为!',
'chrono'=>1,
'author'=>'zyblog',
],[
'pid'=>2,
'subject'=>'三号DEMO的,测试第二篇',
'message'=>'这里是第二篇文章的内容',
'chrono'=>1314336160,
// 'author'=>'zyblog',
],[
'pid'=>3,
'subject'=>'三号DEMO的,项目测试第三篇',
'message'=>'俗话说,无三不成礼,所以就有了第三篇',
'chrono'=>123,
// 'author'=>'虎力大仙',
]
];
foreach($data as $d){
$doc = new XSDocument;
$doc->setFields($d);
$xs->index->add($doc);
}
}
$doc = $xs->search->search("");
print_r($doc);
}