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 (141 lines) | stat: -rw-r--r-- 4,028 bytes parent folder | download | duplicates (5)
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
<?xml version="1.0" encoding="utf-8"?>
<test>

<name>Multi queries + (plain|rt|dist)indexes + group by</name>

<config>
indexer
{
	mem_limit		= 16M
}

searchd
{
	<searchd_settings/>
	workers = threads
}

source test1
{
	type			= mysql
	<sql_settings/>
	sql_query		= select * from test_table1
	sql_attr_uint	= gid
}

source test2
{
	type			= mysql
	<sql_settings/>
	sql_query		= select * from test_table2
	sql_attr_uint	= gid
}

index test_plain
{
	source			= test1
	path			= <data_path/>/test_plain
}

index test_plain_for_dist
{
	source	= test2
	path	= <data_path/>/test_plain_for_dist
}

index test_rt
{
        type                    = rt
        path                    = data/test_rt
        rt_attr_uint    = gid
        rt_field                = title
}

index test_dist
{
	type = distributed
	agent = <agent0_address/>:test_plain_for_dist
}
</config>

<db_create>
CREATE TABLE test_table1
(
	id INTEGER PRIMARY KEY NOT NULL,
	gid INTEGER NOT NULL,
	title VARCHAR(255) NOT NULL
);
</db_create>
<db_drop>DROP TABLE IF EXISTS test_table1;</db_drop>
<db_insert>INSERT INTO test_table1 VALUES ( 1, 1, 'word | 1' );</db_insert>
<db_insert>INSERT INTO test_table1 VALUES ( 2, 2, 'word | 2' );</db_insert>
<db_insert>INSERT INTO test_table1 VALUES ( 3, 2, 'word | 3' );</db_insert>

<db_create>
CREATE TABLE test_table2
(
	id INTEGER PRIMARY KEY NOT NULL,
	gid INTEGER NOT NULL,
	title VARCHAR(255) NOT NULL
);
</db_create>
<db_drop>DROP TABLE IF EXISTS test_table2;</db_drop>
<db_insert>INSERT INTO test_table2 VALUES ( 7, 1, 'word | 7' );</db_insert>
<db_insert>INSERT INTO test_table2 VALUES ( 8, 2, 'word | 8' );</db_insert>
<db_insert>INSERT INTO test_table2 VALUES ( 9, 2, 'word | 9' );</db_insert>

<custom_test><![CDATA[
$run_subtest = create_function ( '&$client, $index1, $index2, &$results, $sd_address, $sd_sphinxql_port', '
{
	$query = "word";

	$client->SetGroupBy ( "gid", SPH_GROUPBY_ATTR );
	$client->AddQuery ( $query, $index1 );

	$client->ResetGroupBy();
	$client->AddQuery ( $query, $index2 );

	$sphinxql = @mysql_connect ( sprintf ( "%s:%s", $sd_address, $sd_sphinxql_port ) );
	@mysql_query ( "DELETE FROM test_rt" );
	@mysql_query ( "INSERT INTO test_rt ( id, gid, title ) VALUES ( 4, 1, \'word | 4\' )" );
	@mysql_query ( "INSERT INTO test_rt ( id, gid, title ) VALUES ( 5, 2, \'word | 5\' )" );
	@mysql_query ( "INSERT INTO test_rt ( id, gid, title ) VALUES ( 6, 2, \'word | 6\' )" );

	$res = $client->RunQueries();

	$query_res = $res[0];
	{
		$results[] = sprintf ( "query: \"%s\" index: %s", $query, $index1 );
		foreach ( $query_res["matches"] as $match )
			$results[] = sprintf ( "\tid: %d, weight: %d, gid: %d, @groupby: %d, @count: %d",
				$match["id"], $match["weight"], $match["attrs"]["gid"], $match["attrs"]["@groupby"], $match["attrs"]["@count"] );
	}
	$query_res = $res[1];
	{
		$results[] = sprintf ( "query: \"%s\" index: %s", $query, $index2 );
		foreach ( $query_res["matches"] as $match )
			$results[] = sprintf ( "\tid: %d, weight: %d, gid: %d",
				$match["id"], $match["weight"], $match["attrs"]["gid"] );
	}
	$results[] = "";
}
' );


$client->SetArrayResult(true);

global $sd_address, $sd_sphinxql_port;

$run_subtest ( $client, "test_plain", "test_plain", $results, $sd_address, $sd_sphinxql_port );
$run_subtest ( $client, "test_rt", "test_rt", $results, $sd_address, $sd_sphinxql_port );
$run_subtest ( $client, "test_dist", "test_dist", $results, $sd_address, $sd_sphinxql_port );

$run_subtest ( $client, "test_plain", "test_rt", $results, $sd_address, $sd_sphinxql_port );
$run_subtest ( $client, "test_plain", "test_dist", $results, $sd_address, $sd_sphinxql_port );
$run_subtest ( $client, "test_rt", "test_dist", $results, $sd_address, $sd_sphinxql_port );
$run_subtest ( $client, "test_rt", "test_plain", $results, $sd_address, $sd_sphinxql_port );
$run_subtest ( $client, "test_dist", "test_plain", $results, $sd_address, $sd_sphinxql_port );
$run_subtest ( $client, "test_dist", "test_rt", $results, $sd_address, $sd_sphinxql_port );
]]></custom_test>

</test>