File: test.xml

package info (click to toggle)
sphinxsearch 2.2.11-8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 25,720 kB
  • sloc: cpp: 102,259; xml: 85,608; sh: 9,259; php: 3,790; ansic: 3,158; yacc: 1,969; java: 1,336; ruby: 1,289; python: 1,062; pascal: 912; perl: 381; lex: 275; makefile: 150; sql: 77; cs: 35
file content (151 lines) | stat: -rw-r--r-- 2,839 bytes parent folder | download | duplicates (6)
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?xml version="1.0" encoding="utf-8"?>

<test>
<name>mva filtering</name>

<requires> <variant_match /> </requires>

<config>
indexer
{
	mem_limit = 16M
}

searchd
{
	<searchd_settings/>
}

source test
{
	type = mysql
	<sql_settings/>

	sql_query = SELECT id, text, mva FROM test_table;
<Dynamic>	
	<Variant>sql_attr_multi = uint mva from field</Variant>
	<Variant>sql_attr_multi = bigint mva from field</Variant>
</Dynamic>	
}

index test
{
	source	= test
	path	= <data_path/>/test
}
</config>

<db_create>
CREATE TABLE test_table
(
	id INTEGER NOT NULL,
	text VARCHAR(255) NOT NULL DEFAULT 'text',
	mva VARCHAR(255) NOT NULL
)
</db_create>

<db_drop>
DROP TABLE IF EXISTS test_table
</db_drop>

<db_insert>
INSERT INTO test_table (id, mva) VALUES
	( 10, '' ),
	(  1, '100' ),
	(  2, '100, 200' ),
	(  4, '6, 12, 17, 20')
</db_insert>

<custom_test><![CDATA[

$ID = 4;
$results = array();

// values
$results [] = 'VALUES';
$results [] = array();
$filters = array(
	array(  0, false),
	array(  7, false),
	array( 15, false),
	array( 21, false),

	array(  3,  8, 16, false),
	array(  7, 18, 21, false),
	
	array(  6, true),
	array( 12, true),
	array( 20, true),

	array(  5, 12, true),
	array(  7, 17, true),
	array( 15, 20, true),
);

$key = count($results) - 1;
foreach ( $filters as &$filter )
{
	$last = count($filter) - 1;
	$mva = array_slice ( $filter, 0,  $last );
	
	$client->ResetFilters();
	$client->SetFilter ( 'mva', $mva );
	$result = $client->Query ( '' );
	if ( !$result )
		break;

	$len = array_key_exists ( 'matches', $result ) ? count ( $result['matches'] ) : 0;
	$pass = $len == $filter[$last] ? 1 : 0;
	if ( $len == 1)
 		$pass = $pass and array_key_exists ( $ID, $result['matches'] );
	$results [$key] [ join(', ', $mva ) ] = $pass ? 'OK' : 'FAILED';
	
}

// interval
$results [] = 'INTERVAL';
$results [] = array();
$filters = array(
	array(  1,  4, false),
	array(  1,  5, false),
	array(  1,  6, true),
	array(  1,  7, true),
	array(  1, 12, true),
	array(  1, 15, true),
	
	array(  6,  9, true),
	array(  7,  9, false),
	array(  8, 10, false),
	array(  9, 12, true),
	array(  9, 15, true),
	array(  9, 21, true),
	array( 16, 21, true),
	array( 17, 21, true),
	array( 18, 19, false),
    
	array( 18, 25, true),
	array( 19, 25, true),
	array( 20, 25, true),

	array( 21, 25, false),
);

$key = count($results) - 1;
foreach ( $filters as &$filter )
{
	$client->ResetFilters();
	$client->SetFilterRange ( 'mva', $filter[0], $filter[1] );
	$result = $client->Query ( '' );
	if ( !$result )
		break;
	
	$len = array_key_exists ( 'matches', $result ) ? count ( $result['matches'] ) : 0;
	$pass = $len == ( $filter[2] ? 1 : 0 );
	if ( $len == 1)
		$pass = $pass and array_key_exists ( $ID, $result['matches'] );
	$results [$key] [$filter[0] . ' - ' . $filter[1]] = $pass ? 'OK' : 'FAILED';
}

]]></custom_test>

</test>