<?xml version="1.0" encoding="utf-8"?>
<Test>
<Name>tail hits vs UNIT node</Name>

<requires>
<non-rt/>
</requires>

<Config>
indexer
{
	mem_limit			= 16M
}

searchd
{
<Searchd_Settings/>
}

source src1
{
	type			= mysql
<Sql_Settings/>

	sql_query = SELECT * FROM test_table where gid=1
	sql_attr_uint = gid
}

index test1
{
	source			= src1
	path			= <Data_Path/>/test1
	html_strip		= 1
	index_sp		= 1
}

source src2
{
	type			= mysql
<Sql_Settings/>

	sql_query = SELECT * FROM test_table2
	sql_attr_uint = gid
}

index test2
{
	source			= src2
	path			= <Data_Path/>/test2
	docinfo		= extern
	html_strip		= 1
	index_sp		= 1
	index_zones = z_*
}

source src3
{
	type			= mysql
<Sql_Settings/>

	sql_query = SELECT * FROM test_table3
	sql_attr_uint = gid
}

index test3
{
	source			= src3
	path			= <Data_Path/>/test3
	docinfo		= extern
}

</Config>
<DB_Create>
CREATE TABLE test_table
(
	id INTEGER NOT NULL,
	gid INTEGER NOT NULL,
	title VARCHAR(16384) NOT NULL
)
</DB_Create>
<DB_Drop>DROP TABLE IF EXISTS test_table</DB_Drop>
<db_insert>insert into test_table values ( 1, 1, 'aa bb cc' )</db_insert>
<db_insert>insert into test_table values ( 2, 1, 'aa bb' )</db_insert>
<db_insert>insert into test_table values ( 3, 1, 'aa bb' )</db_insert>
<db_insert>insert into test_table values ( 4, 1, CONCAT(REPEAT('aa bb. ', 512), 'aa bb. '))</db_insert>
<db_insert>insert into test_table values ( 5, 1, 'cc' )</db_insert>
<db_insert>insert into test_table values ( 6, 1, 'cc' )</db_insert>

<db_create>
CREATE TABLE test_table2
(
	id INTEGER NOT NULL,
	gid INTEGER NOT NULL,
	title VARCHAR(6048) NOT NULL
)
</db_create>
<db_drop>DROP TABLE IF EXISTS test_table2</db_drop>
<db_insert>insert into test_table2 values ( 1, 1, 'aa' )</db_insert>
<db_insert>insert into test_table2 values ( 2, 1, 'aa' )</db_insert>
<db_insert>insert into test_table2 values ( 3, 1, 'aa' )</db_insert>
<db_insert>insert into test_table2 values ( 4, 1, 'aa' )</db_insert>
<db_insert>insert into test_table2 values ( 5, 1, 'aa' )</db_insert>
<db_insert><![CDATA[insert into test_table2 values ( 6, 1, '<z_1>aa</z_1>' )]]></db_insert>
<db_insert><![CDATA[insert into test_table2 values ( 7, 1, '<z_1>aa</z_1>' )]]></db_insert>
<db_insert><![CDATA[insert into test_table2 values ( 8, 1, '<z_1>aa</z_1>' )]]></db_insert>
<db_insert><![CDATA[insert into test_table2 values ( 9, 1, CONCAT('<z_1> ', CONCAT(REPEAT('aa ', 512), ' </z_1>')) )]]></db_insert>
<db_insert><![CDATA[insert into test_table2 values ( 10, 1, '<z_1> aa </z_1>' )]]></db_insert>
<db_insert><![CDATA[insert into test_table2 values ( 11, 1, '<z_1> aa </z_1>' )]]></db_insert>

<db_create>
CREATE TABLE test_table3
(
	id BIGINT NOT NULL,
	gid INTEGER NOT NULL,
	title VARCHAR(6048) NOT NULL
)
</db_create>
<db_drop>DROP TABLE IF EXISTS test_table3</db_drop>
<db_insert>insert into test_table3 values ( 3452816845, 3, 'match1 and match2 vs match3' )</db_insert>

<sphqueries>
	<sphinxql>select * from test1 where match('aa SENTENCE bb')</sphinxql>	
	<sphinxql>select * from test1 where match('(aa SENTENCE bb) cc')</sphinxql>	
	<sphinxql>CALL SNIPPETS ('dummy1 match1 dummy2 match2', 'test1', ' ( match1 NEAR/3 match2 ) | ^missed1 | missed2 ', 1 as query_mode)</sphinxql>
	<!-- here is another regression -->
	<sphinxql>select * from test2 where match('(ZONE:z_1 aa )') order by id asc</sphinxql>	
	<!-- here is another regression Order with Or parent -->
	<sphinxql><![CDATA[select * from test3 where match ( ' match1 | ( match5 << match2) ' ) ]]></sphinxql>	
</sphqueries>

</Test>
