-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueryManager.php
More file actions
72 lines (55 loc) · 1.52 KB
/
Copy pathqueryManager.php
File metadata and controls
72 lines (55 loc) · 1.52 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
<?php
$time_start = microtime(true);
error_reporting(0);
include 'functions.php';
$intersect = Array();
$query = trim(htmlspecialchars($_POST['keyword']));
$query = applyLowerCase($query);
$tokens = makeQueryTokens($query);
$tokens = removeStopWords($tokens);
$tokens = removeNumericTokens($tokens);
foreach ($tokens as $val)
{
$result = doSearch($val);
if($result)
{
echo "<div id='queryWord'>".$val."</div>";
echo "<div id='queryResult'>".$result."</div>";
$intersect[] = $result;
}
else
echo "<p style='color:red;'>No result found for ".$val."</p>";
}
if(count($intersect) == 2)
{
$int1 = explode(",", $intersect[0]);
$int2 = explode(",", $intersect[1]);
$union = array_unique(array_merge($int1,$int2));
$int_final = array_intersect($int1, $int2);
}
if(count($intersect) == 3)
{
$int1 = explode(",", $intersect[0]);
$int2 = explode(",", $intersect[1]);
$int3 = explode(",", $intersect[2]);
$union_temp = array_unique(array_merge($int1,$int2));
$union = array_unique(array_merge($union_temp,$int3));
$int_temp = array_intersect($int1, $int2);
$int_final = array_intersect($int_temp, $int3);
}
if(!empty($int_final)){
echo "<div id='queryWord'>".$query." (AND)</div>";
foreach ($int_final as $value) {
echo $value. "<br />";
}
}
if(!empty($union)) {
echo "<div id='queryWord'>".$query." (OR)</div>";
foreach ($union as $value) {
echo $value. "<br />";
}
}
$time_end = microtime(true);
$time = $time_end - $time_start;
echo "<br /><br />Search time is : <b> ".round($time,2)." microseconds</b>";
?>