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 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
|
<?xml version="1.0" encoding="utf-8"?>
<test>
<name>RT: kill-list and segments merge</name>
<config>
searchd
{
<searchd_settings/>
seamless_rotate = 1
workers = threads
binlog_path =
}
index test
{
type = rt
path = <data_path/>/testrt123
rt_mem_limit = 128K
rt_attr_uint = group_id
rt_field = title
rt_field = content
}
index seg1
{
type = rt
path = <data_path/>/seg1
rt_mem_limit = 32K
rt_attr_uint = gid
rt_field = body
}
indexer
{
mem_limit = 16M
}
source dummysrc
{
type = mysql
<sql_settings/>
sql_query = SELECT * FROM test_table where id=1
}
index dummysrcmain
{
source = dummysrc
path = <data_path/>/dummysrcmain
}
source src_1
{
type = mysql
<sql_settings/>
sql_query = SELECT *, 11 as idd FROM test_table where id <= 100
sql_attr_uint = idd
}
source src_2
{
type = mysql
<sql_settings/>
sql_query = SELECT *, 11 as idd FROM test_table where id > 100
sql_attr_uint = idd
}
index i1_crc
{
source = src_1
path = <data_path/>/i1_crc
docinfo = extern
dict = crc
}
index i2_crc
{
source = src_2
path = <data_path/>/i2_crc
docinfo = extern
dict = crc
}
index i1_kw
{
source = src_1
path = <data_path/>/i1_kw
docinfo = extern
dict = keywords
}
index i2_kw
{
source = src_2
path = <data_path/>/i2_kw
docinfo = extern
dict = keywords
}
</config>
<db_create>
CREATE TABLE test_table
(
id INTEGER PRIMARY KEY NOT NULL AUTO_INCREMENT,
title varchar(255) NOT NULL
);
</db_create>
<db_drop>
DROP TABLE IF EXISTS test_table;
</db_drop>
<custom_insert><![CDATA[
$q = "( 1, 'dummy word not another' )";
for ( $i=2; $i<1000; $i++ )
$q .= ", ( $i, 'dummy word not another' )";
mysql_query ( "insert into test_table values $q" );
]]></custom_insert>
<custom_test><![CDATA[
global $g_locals, $sd_address, $sd_sphinxql_port;
RunIndexer ( $errors, '--rotate --merge i1_crc i2_crc' );
RunIndexer ( $errors, '--rotate --merge i1_kw i2_kw' );
usleep ( 100000 );
$results = array();
$sockStr = "$sd_address:$sd_sphinxql_port";
if ($sd_address == "localhost")
$sockStr = "127.0.0.1:$sd_sphinxql_port";
$sock = @mysql_connect (
$sockStr,
$g_locals['db-user'],
$g_locals['db-password'] ,
true );
if ( $sock === false )
{
$results[] = "error: can't connect to searchd: " . @mysql_errno ( $sock ) . " : " . @mysql_error ( $sock );
return;
}
$title = "";
$ctx = "";
for ( $i=1; $i<20; $i++ )
{
$title .= " title$i";
$ctx .= " ctx$i";
}
$inserted = 0;
for ( $i=1; $i<1020; $i++ )
{
$group = $i + 10000;
$str = "";
if ( $i == 450 || $i == 550 || $i == 900 )
$str = "REPLACE INTO test ( id, group_id, title, content ) VALUES ( 21, $group, '$title', 'there is gooddy stuff' )";
else
$str = "INSERT INTO test ( id, group_id, title, content ) VALUES ( $i, $group, '$title', '$ctx' )";
$res = @mysql_query ($str, $sock );
if ($res===true)
{
$inserted += mysql_affected_rows($sock);
}
else
{
$results[] = "error: insert: " . @mysql_errno ( $sock ) . " : " . @mysql_error ( $sock );
return;
}
}
$results[] = "total inserted=$inserted";
$queries = array ( "id=21", "match('gooddy')" );
for ( $i=0; $i<count ( $queries ); $i++ )
{
$q = "select * from test where $queries[$i]";
$res = @mysql_query ( $q, $sock );
if ($res===true)
{
$results[] = "query $i: total_affected=" . mysql_affected_rows($sock);
}
else if ($res===false)
{
$results[] = "query $i: res=$res";
$results[] = "error: query: " . @mysql_errno ( $sock ) . " : " . @mysql_error ( $sock );
return;
}
else
{
$results[] = $queries[$i] . " query $i: total_rows=" . @mysql_num_rows($res);
while ($row = @mysql_fetch_array($res, MYSQL_ASSOC))
{
foreach ($row as $key => $value)
$foo[$key] = $value;
$results[] = $foo;
}
}
}
$replaced = 0;
$queried = 0;
for ( $i=0; $i<50; $i++ )
{
$res = array ();
$res[] = @mysql_query ( "REPLACE INTO seg1 ( id, gid, body ) VALUES ( $i, $i, 'text $i' )" );
$res[] = @mysql_query ( "REPLACE INTO seg1 ( id, gid, body ) VALUES ( $i, $i, 'text $i' )" );
foreach ( $res as $r )
{
if ($r===true)
$replaced++;
}
$rq = @mysql_query ( "SELECT * FROM seg1 WHERE MATCH('text')" );
$queried += mysql_num_rows ($rq);
}
$results[] = "segments merge: replaced=$replaced, queried=$queried";
// issues with merge+rotate and merge of indexes v31
$queryAPI = create_function('$client,$words,$idx', '
$result = $client->Query ( $words, $idx ); if ( $result ) { unset ( $result["time"] ); return $result; } else return $client->GetLastError();
');
usleep ( 100000 );
$client->SetLimits ( 0, 1 );
$results[] = "merge+rotate and merge of indexes v31";
$results[] = $queryAPI ( $client, ' dummy ', 'i1_crc' );
$results[] = $queryAPI ( $client, ' dummy ', 'i1_kw' );
@mysql_close($sock);
]]></custom_test>
</test>
|