<?xml version="1.0" encoding="utf-8"?>
<test>
<name>block index vs MVA</name>

<requires> <variant_match /> </requires>

<config>
indexer
{
	mem_limit			= 16M
}

searchd
{
	<searchd_settings/>
}

source src_base
{
	type			= mysql
	<sql_settings/>
}	
<Dynamic>
<Variant>
source src1 : src_base
{
	sql_query = SELECT document_id, text, mva1 FROM main_table
	sql_attr_multi = uint mva2 from query; SELECT word_document_id, word_tag_id FROM tag_table;
	sql_attr_multi = uint mva1 from field mva1
}
source src2 : src_base
{
	sql_query = SELECT document_id, text, attr1, mva1 FROM main_table2
	sql_attr_multi = uint mva1 from field mva1
	sql_attr_uint = attr1	
}
source src3 : src_base
{
	sql_query = SELECT document_id, text, mva1 FROM main_table3
	sql_attr_multi = uint mva2 from query; SELECT word_document_id, word_tag_id FROM tag_table;
	sql_attr_multi = uint mva1 from field mva1
}
source src4 : src_base
{
	sql_query = SELECT document_id, text, mva1 FROM main_table2
	sql_attr_multi = uint mva2 from query; SELECT word_document_id, word_tag_id FROM tag_table;
	sql_attr_multi = uint mva1 from field mva1
	sql_attr_str2ordinal = text	
}
</Variant>
<Variant>
source src1 : src_base
{
	sql_query = SELECT document_id, text, mva1 FROM main_table
	sql_attr_multi = bigint mva2 from query; SELECT word_document_id, word_tag_id FROM tag_table;
	sql_attr_multi = bigint mva1 from field mva1
}
source src2 : src_base
{
	sql_query = SELECT document_id, text, attr1, mva1 FROM main_table2
	sql_attr_multi = bigint mva1 from field mva1
	sql_attr_uint = attr1	
}
source src3 : src_base
{
	sql_query = SELECT document_id, text, mva1 FROM main_table3
	sql_attr_multi = bigint mva2 from query; SELECT word_document_id, word_tag_id FROM tag_table;
	sql_attr_multi = bigint mva1 from field mva1
}
source src4 : src_base
{
	sql_query = SELECT document_id, text, mva1 FROM main_table2
	sql_attr_multi = bigint mva2 from query; SELECT word_document_id, word_tag_id FROM tag_table;
	sql_attr_multi = bigint mva1 from field mva1
	sql_attr_str2ordinal = text	
}
</Variant>
</Dynamic>
index main
{
<dynamic>
	<variant>source = src1</variant>
	<variant>source = src2</variant>
	<variant>source = src3</variant>
<!--	<variant>source = src4</variant>
-->
</dynamic>
	path			= <data_path/>/main1
	docinfo			= extern
	charset_type	= utf-8
	min_word_len	= 1
}
</config>

<queries>
	<query>test1</query>
	<query>test511</query>
	<query>test2048</query>
	<query>test4000</query>
	<query index="main" filter="attr1" filter_value="101"></query>
	<query index="main" filter="attr1" filter_value="164"></query>
	<query index="main" filter="attr1" filter_value="165"></query>
	<query index="main" filter="attr1" filter_value="227"></query>
	<query index="main" filter="attr1" filter_value="228"></query>
	<query index="main" filter="attr1" filter_value="229"></query>
	<query index="main" filter="attr1" filter_value="230"></query>
</queries>

<db_create>
CREATE TABLE `main_table` (
  `document_id` int(11),
  `text` varchar(255) NOT NULL,
  `mva1` varchar(255) NOT NULL
);
</db_create>
<db_create>
CREATE TABLE `main_table2` (
  `document_id` int(11) DEFAULT NULL,
  `text` varchar(255) NOT NULL,
  `attr1` int(11) DEFAULT NULL,
  `mva1` varchar(255) NOT NULL
);
</db_create>
<db_create>
CREATE TABLE `main_table3` (
  `document_id` int(11),
  `text` varchar(255) NOT NULL,
  `mva1` varchar(255) NOT NULL
);
</db_create>
<db_create>
CREATE TABLE `tag_table` (
  `word_document_id` int(11) NOT NULL,
  `word_tag_id` int(11) NOT NULL
);
</db_create>

<db_drop>
DROP TABLE IF EXISTS `main_table`
</db_drop>
<db_drop>
DROP TABLE IF EXISTS `main_table2`
</db_drop>
<db_drop>
DROP TABLE IF EXISTS `main_table3`
</db_drop>
<db_drop>
DROP TABLE IF EXISTS `tag_table`
</db_drop>

<db_insert>
INSERT INTO `main_table` VALUES
( 1, 'test1',  'mva1' ),
( 511, 'test511',  'mva511' ),
( 2048, 'test2048',  'mva2048' ),
( 4000, 'test4000',  'mva4000' );
</db_insert>

<custom_insert><![CDATA[
$vals = array();
for ($i=1; $i<145; ++$i)
	$vals[] = sprintf ("(%d,'test%d',%d,'%d')",$i,$i,100+$i,1000+$i);
mysql_query ("INSERT INTO main_table2 VALUES ".join(',',$vals));

$vals = array();
for ($i=1; $i<128; ++$i)
	$vals[] = sprintf ("(%d,'test%d','%d')",$i,$i,1000+$i);
mysql_query ("INSERT INTO main_table3 VALUES ".join(',',$vals));

$vals = array();
for ($i=1; $i<5001; ++$i)
	$vals[] = sprintf ("(%d,%d)",$i,$i+1);
mysql_query ("INSERT INTO tag_table VALUES (1,1),".join(',',$vals));
]]></custom_insert>

</test>
