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

<test>
<name>blend_chars vs multiforms</name>

<config>
searchd
{
	<searchd_settings/>
}

source test
{
	type = mysql
	<sql_settings/>
	sql_query = \
		SELECT 1, 'text' AS content UNION \
		SELECT 2, '3+rd text' AS content UNION \
		SELECT 3, '3-rd text' AS content UNION \
		SELECT 4, '3@rd text' AS content
}

index test
{
	source			= test
	path			= <data_path/>/test

	wordforms		= <this_test/>/wordforms.txt
	blend_chars		= +, U+2D, @
    min_word_len	= 2
}

source test1
{
	type = mysql
	<sql_settings/>
	sql_query = SELECT 1, 'test 3+3+3+3+real text' AS content
}

index test10
{
	source			= test1
	path			= <data_path/>/test10

	charset_table	= 0..9, A..Z->a..z, _, a..z
	blend_chars		= +
	min_word_len	= 2
}

index test11
{
	source			= test1
	path			= <data_path/>/test11

	charset_table	= 0..9, A..Z->a..z, _, a..z
	blend_chars		= +
	min_word_len	= 2
	min_prefix_len = 2
}

source wb
{
	type = mysql
	<sql_settings/>
	sql_query = \
		SELECT 1, 'ru-tor' AS content UNION \
		SELECT 2, 'pu-tor' AS content  UNION \
		SELECT 10, 'rd the box' AS content  UNION \
		SELECT 11, 'test+the box' AS content UNION \
		SELECT 12, 'the-box-of-my goes-here' as content
}

index wb
{
	source			= wb
	path			= <data_path/>/wb

	wordforms		= <this_test/>/wordforms-wb.txt
	blend_chars		=  U+2D
}


source test12
{
	type = mysql
	<sql_settings/>
	sql_query_pre = SET NAMES utf8
	sql_query = \
		SELECT 1, 'путин-то' AS content UNION \
		SELECT 2, 'путиными' AS content  UNION \
		SELECT 3, 'путена' AS content UNION \
		SELECT 4, 'Военно-промышленная комиссия превратилась в авторитетную площадку диалога' AS content
}


index test12
{
	source			= test12
	path			= <data_path/>/test12

	wordforms		= <this_test/>/wordforms-12.txt
	morphology		= stem_enru
	min_prefix_len	= 3
	html_strip		= 1
	index_exact_words	= 1
	blend_mode		= trim_head, trim_tail, trim_both
	blend_chars 	= +, %, -, $
}


</config>

<db_insert>select 1;</db_insert>

<sphqueries>
<sphinxql>SELECT * FROM test WHERE MATCH('3+rd text')</sphinxql>
<sphinxql>SHOW META</sphinxql>
<sphinxql>SELECT * FROM test WHERE MATCH('3-rd text')</sphinxql>
<sphinxql>SHOW META</sphinxql>
<sphinxql>SELECT * FROM test WHERE MATCH('3\\@rd text')</sphinxql>
<sphinxql>SHOW META</sphinxql>
<sphinxql>CALL KEYWORDS ( 'man', 'test' )</sphinxql>
<!-- regression - incomplete multi-form vs blended part with wrong hit position -->
<sphinxql>SELECT * FROM test WHERE MATCH('"a rd text"')</sphinxql>
<sphinxql>SHOW META</sphinxql>
<!-- regression - blended part vs overshort -->
<sphinxql>SELECT * FROM test10 WHERE MATCH('"test a text"')</sphinxql>
<sphinxql>SHOW META</sphinxql>
<sphinxql>SELECT * FROM test11 WHERE MATCH('"test a text"')</sphinxql>
<sphinxql>SHOW META</sphinxql>
<sphinxql>CALL SNIPPETS ( 'test 3+3+3+3+real text' , 'test10', ' "test a text" ', 1 as query_mode )</sphinxql>
<sphinxql>CALL SNIPPETS ( 'test 3+3+3+3+real text' , 'test10', ' "test a text" ', 0 as query_mode )</sphinxql>
<sphinxql>CALL SNIPPETS ( 'test 3+3+3+3+real text' , 'test10', ' "test a text" ', 1 as query_mode, 0 as limit )</sphinxql>
<sphinxql>CALL SNIPPETS ( 'test 3+3+3+3+real text' , 'test10', ' "test a text" ', 0 as query_mode, 0 as limit )</sphinxql>
<sphinxql>SELECT * FROM test WHERE MATCH(' " 3 rd text " ')</sphinxql>
<sphinxql>SHOW META</sphinxql>
<!-- regression - incomplete multi-form vs blended part -->
<sphinxql>CALL SNIPPETS ( 'the+ rd box+ must ' , 'test', ' not found ', 1 as query_mode, 0 as limit )</sphinxql>
<sphinxql>SELECT * FROM test WHERE MATCH('other+none text')</sphinxql>
<sphinxql>SHOW META</sphinxql>
<sphinxql>CALL SNIPPETS ('черно-белый, черно-белая, черно-белым  черно-белыми', 'wb', 'черно-белый')</sphinxql>
<sphinxql>SELECT * FROM wb WHERE MATCH ( ' ru-tor ' )</sphinxql>
<sphinxql>SELECT * FROM wb WHERE MATCH ( ' ru tor ' )</sphinxql>
<sphinxql>SELECT * FROM wb WHERE MATCH ( ' pu-tor ' )</sphinxql>
<sphinxql>SELECT * FROM wb WHERE MATCH ( ' pu tor ' )</sphinxql>
<sphinxql>SELECT * FROM wb WHERE MATCH ( ' "ru tor" ' )</sphinxql>
<sphinxql>SELECT * FROM wb WHERE MATCH ( ' "pu tor" ' )</sphinxql>
<sphinxql>CALL KEYWORDS ( 'ru-tor', 'wb' )</sphinxql>
<sphinxql>CALL KEYWORDS ( 'ru tor', 'wb' )</sphinxql>
<sphinxql>CALL KEYWORDS ( 'pu-tor', 'wb' )</sphinxql>
<sphinxql>CALL KEYWORDS ( 'pu tor', 'wb' )</sphinxql>

<sphinxql>SELECT * FROM wb WHERE MATCH(' "the box" ')</sphinxql>
<sphinxql>SHOW META</sphinxql>
<sphinxql>SELECT * FROM wb WHERE MATCH(' the box ')</sphinxql>
<sphinxql>SHOW META</sphinxql>
<sphinxql>SELECT * FROM wb WHERE MATCH(' rd text ')</sphinxql>
<sphinxql>SHOW META</sphinxql>
<sphinxql>CALL SNIPPETS( 'the-box-of-my goes-here', 'wb', 'the-box-of-my goes-here', 1 as query_mode)</sphinxql>
<sphinxql>CALL SNIPPETS( 'the-box-of-my goes-here', 'wb', 'the-box-of goes-here', 1 as query_mode)</sphinxql>
<sphinxql>CALL SNIPPETS( 'the-box-of-my goes-here', 'wb', 'box-of-my goes-here', 1 as query_mode)</sphinxql>
<sphinxql>SELECT * FROM wb WHERE MATCH('the-box-of-my goes-here')</sphinxql>
<sphinxql>SELECT * FROM wb WHERE MATCH('the-box-of goes-here')</sphinxql>
<sphinxql>SELECT * FROM wb WHERE MATCH('box-of-my goes-here')</sphinxql>

<sphinxql>SELECT * FROM test12 WHERE MATCH('путин')</sphinxql>
<sphinxql>SELECT * FROM test12 WHERE MATCH('путин-то')</sphinxql>
<sphinxql>SELECT * FROM test12 WHERE MATCH('"Военно-промышленная комиссия"')</sphinxql>
</sphqueries>

</test>
