<?xml version="1.0" encoding="utf-8"?>
<test>

<name>string attribute vs different indexes, attributes UNION</name>

<num_agents>3</num_agents>

<config>

indexer
{
	mem_limit		= 16M
}

searchd
{
	<searchd_settings/>
	workers = threads
	<dynamic>
		<variant>compat_sphinxql_magics = 1</variant>
		<variant>compat_sphinxql_magics = 0</variant>
	</dynamic>
}

source src_main
{
	type			= mysql
	<sql_settings/>

	sql_query		= SELECT id, body, CONCAT(str1, ' main') AS str1, idd1, 100 as tag FROM test_table
	sql_attr_uint	= idd1
	sql_attr_uint	= tag
	sql_attr_string = str1
}

source src_delta1
{
	type			= mysql
	<sql_settings/>
	
	sql_query		= SELECT id, body, CONCAT(str1, ' delta1') AS str1, idd1, 101 as tag FROM test_table where id>3
	sql_attr_uint	= idd1
	sql_attr_uint	= tag
	sql_attr_string = str1
	sql_query_killlist = SELECT 2
}

source src_delta2
{
	type			= mysql
	<sql_settings/>

	sql_query		= SELECT id, body, 'delta2' as str1, CONCAT(str1, ' delta2') AS str2, idd1, 102 as tag FROM test_table where id>4
	sql_attr_uint	= idd1
	sql_attr_uint	= tag
	sql_attr_string = str1
	sql_attr_string = str2
	sql_query_killlist = SELECT 2
}

<agent0>
index main
{
	source			= src_main
    docinfo			= extern
    charset_type	= sbcs
	path			= <data_path/>/main
}

index delta1
{
	source			= src_delta1
    docinfo			= extern
    charset_type	= sbcs
	path			= <data_path/>/delta1
}

index delta2
{
	source			= src_delta2
    docinfo			= extern
    charset_type	= sbcs
	path			= <data_path/>/delta2
}

index loc_dist1
{
	type = distributed
	local = main
	local = delta1
}

index loc_dist2
{
	type = distributed
	local = main
	local = delta2
}

index dist1
{
	type = distributed
	local = main
	agent = <agent1_address/>:agent1_delta2
}

index dist2
{
	type = distributed
	local = delta2
	agent = <agent2_address/>:agent2_delta1
}

index dist3
{
	type = distributed
	agent = <agent1_address/>:agent1_main
	agent = <agent2_address/>:agent2_delta1
}

source src_bool
{
	type			= mysql
	<sql_settings/>
	sql_query		= SELECT id, body, idd1>2 as attr FROM test_table
	sql_attr_bool	= attr
}
source src_uint
{
	type			= mysql
	<sql_settings/>
	sql_query		= SELECT id, body, idd1*100 as attr FROM test_table
	sql_attr_uint	= attr
}
source src_float
{
	type			= mysql
	<sql_settings/>
	sql_query		= SELECT id, body, idd1/1.73 as attr FROM test_table
	sql_attr_float	= attr
}
source src_bigint
{
	type			= mysql
	<sql_settings/>
	sql_query		= SELECT id, body, idd1*100000000000 as attr FROM test_table
	sql_attr_bigint	= attr
}

index u_bool
{
	source			= src_bool
    docinfo			= extern
	path			= <data_path/>/u_bool
}
index u_uint
{
	source			= src_uint
    docinfo			= extern
	path			= <data_path/>/u_uint
}
index u_float
{
	source			= src_float
    docinfo			= extern
	path			= <data_path/>/u_float
}
index u_bigint
{
	source			= src_bigint
    docinfo			= extern
	path			= <data_path/>/u_bigint
}

index u_dist10
{
	type = distributed
	local = u_bool
	local = u_float
}
index u_dist11
{
	type = distributed
	local = u_float
	local = u_bool
}
index u_dist20
{
	type = distributed
	local = u_bool
	local = u_uint
	local = u_bigint
}
index u_dist21
{
	type = distributed
	local = u_bool
	local = u_bigint
	local = u_uint
}
index u_dist22
{
	type = distributed
	local = u_bigint
	local = u_bool
	local = u_uint
}
index u_dist23
{
	type = distributed
	local = u_bigint
	local = u_uint
	local = u_bool
}
</agent0>

<agent1>
index agent1_main
{
	source			= src_main
    docinfo			= extern
    charset_type	= sbcs
	path			= <data_path/>/agent1_main
}

index agent1_delta2
{
	source			= src_delta2
    docinfo			= extern
    charset_type	= sbcs
	path			= <data_path/>/agent1_delta2
}
</agent1>

<agent2>
index agent2_delta1
{
	source			= src_delta1
    docinfo			= extern
    charset_type	= sbcs
	path			= <data_path/>/agent2_delta1
}
</agent2>


</config>

<db_create>
CREATE TABLE `test_table`
(
	`id` int(11) NOT NULL default '0',
	`idd1` int(11) NOT NULL default '0',
	`str1` varchar(255) NOT NULL default '',
	`body` varchar(255) NOT NULL default ''
)
</db_create>

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

<db_insert>
INSERT INTO `test_table` VALUES
( 1, 1,		'a aa',		'the dog' ),
( 2, 11,	'c cc',		'the cat' ),
( 3, 11,	'a a',		'the bird' ), 
( 4, 11,	'cc c',		'cat eats bird' ),
( 5, 3, 	'a a',		'dog eats cat' ), 
( 6, 1,		'c cc',		'bird' ), 
( 7, 1,		'a a',		'the cat' ),
( 8, 1,		'a a',		'eats' ),
( 9, 3, 	'c cc',		'the' )
</db_insert>

<sphqueries>
<sphinxql>select * from loc_dist1 order by str1 asc</sphinxql>
<sphinxql>select * from loc_dist1 order by str1 desc</sphinxql>
<sphinxql>select * from loc_dist2 order by str1 asc, idd1 desc</sphinxql>
<sphinxql>select * from loc_dist2 order by str1 desc, idd1 asc</sphinxql>
<sphinxql>select * from loc_dist2 order by str2 asc</sphinxql>
<sphinxql>select * from loc_dist2 order by str2 desc</sphinxql>
<sphinxql>select * from loc_dist2 order by str2 desc, idd1 desc</sphinxql>
<sphinxql>select * from dist1 order by str2 asc, idd1 desc</sphinxql>
<sphinxql>select * from dist1 order by str2 desc, idd1 asc</sphinxql>
<sphinxql>select * from dist2 order by str1 asc</sphinxql>
<sphinxql>select * from dist2 order by str1 desc</sphinxql>
<sphinxql>select * from dist3 order by str1 asc</sphinxql>
<sphinxql>select * from dist3 order by str1 desc, idd1 desc</sphinxql>

<!-- here is going new feature seamless conversion of result set attributes ( bool -> float ) | ( bool -> uint -> bigint ) -->
<sphinxql>select * from u_bool, u_float</sphinxql>
<sphinxql>select * from u_float, u_bool</sphinxql>
<sphinxql>select * from u_bool, u_uint, u_bigint</sphinxql>
<sphinxql>select * from u_uint, u_bool, u_bigint</sphinxql>
<sphinxql>select * from u_uint, u_bigint, u_bool</sphinxql>
<sphinxql>select * from u_bigint, u_uint, u_bool </sphinxql>
<sphinxql>select * from u_dist10</sphinxql>
<sphinxql>select * from u_dist11</sphinxql>
<sphinxql>select * from u_dist20</sphinxql>
<sphinxql>select * from u_dist21</sphinxql>
<sphinxql>select * from u_dist22</sphinxql>
<sphinxql>select * from u_dist23</sphinxql>
<!-- still invalid -->
<sphinxql>select * from u_float, u_uint</sphinxql>
<sphinxql>select * from u_float, u_bigint</sphinxql>
<sphinxql>select * from u_uint, u_float</sphinxql>
<sphinxql>select * from u_bigint, u_float</sphinxql>
</sphqueries>

</test>
