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

<requires>
<lemmatizer_base/>
</requires>

<name>cooperation of index_exact_word with expanding by lematizer, expand</name>

<config>
common
{
	lemmatizer_base	= <local>lemmatizer_base</local>
}

searchd
{
	<searchd_settings/>
	workers				= threads
}

source test1
{
	type			= mysql
	<sql_settings/>
	sql_query_pre	= set names utf8
	sql_query		= select * from test_table
	sql_attr_uint	= gid
}

# test with wordforms
index testw
{
	source			= test1
	dict			= keywords
	min_infix_len	= 2
	path			= <data_path/>/testw
	blend_chars		= @, .
	wordforms		= <this_test/>/wordforms.txt
}

# test with wordworms and index_exact
index testwe : testw
{
	path			= <data_path/>/testwe
	index_exact_words = 1
}

# test with crc dict
index testc : testw
{
	path			= <data_path/>/testc
	dict = crc
}

# test with crc dict and index_exact_words
index testce : testc
{
	path			= <data_path/>/testce
	index_exact_words = 1
}

# test with lemmatize_all
index testla
{
	source			= test1
	path			= <data_path/>/testla
	morphology		= lemmatize_ru_all
	blend_chars		= @, .
	wordforms		= <this_test/>/wordforms.txt
}

# test with lemmatize
index testl : testla
{
	path			= <data_path/>/testl
	morphology		= lemmatize_ru
}

# test with lemmatize_all and index_exact_words
index testlae : testla
{
	path			= <data_path/>/testlae
	index_exact_words = 1
	morphology		= stem_en,lemmatize_ru_all
}

# test prefixed
index testpr
{
	source			= test1
	path			= <data_path/>/testpr
	expand_keywords	= 1
	min_prefix_len	= 2
}

# test plain expanded index
index testple
{
	source			= test1
	path			= <data_path/>/testple
	docinfo			= extern
	dict			= keywords
	expand_keywords	= 1
	min_infix_len	= 2
}

source src_plain_ckw
{
	type			= mysql
	<sql_settings/>
	sql_query_pre	= set names utf8
	sql_query		= select 1 as id, 11 as idd, 'фичин баг, но не фичина бага' as title
	sql_attr_uint	= idd
}

index plain_ckw
{
	source			= src_plain_ckw
	dict			= keywords
	path			= <data_path/>/plain_ckw
	morphology		= lemmatize_en_all, lemmatize_ru_all
}

index rt_ckw
{
    type            = rt
    dict            = keywords
    path            = <data_path/>/rt_ckw
    rt_attr_uint    = idd
    rt_field        = title
	morphology		= lemmatize_en_all, lemmatize_ru_all
}


index tmpl_ckw
{
	type			= template
	dict			= keywords
	morphology		= lemmatize_en_all, lemmatize_ru_all
}

</config>

<db_create>
CREATE TABLE test_table
(
	id INTEGER PRIMARY KEY NOT NULL,
	gid INTEGER NOT NULL,
	title VARCHAR(255) CHARACTER SET utf8 NOT NULL
);
</db_create>
<db_drop>DROP TABLE IF EXISTS test_table</db_drop>
<db_insert>SET NAMES utf8</db_insert>
<db_insert>INSERT INTO test_table VALUES
	( 1, 11, 'Фичин баг' ),
	( 2, 11, 'Фичинa баг' ),
	( 3, 11, 'Фичин багa' ),
	( 4, 11, 'Фичинa багa' ),
    ( 10, 11, 'english text' ),
    ( 11, 11, 'englisha text' ),
    ( 12, 11, 'englisha texta' ),
    ( 13, 11, 'english texta' )
</db_insert>
<metaindex name='META:plain'>
<index>testla</index>
<index>testl</index>
<index>testlae</index>
<index>testwe</index>
<index>testw</index>
<index>testce</index>
<index>testc</index>
<index>testpr</index>
<index>testple</index>
</metaindex>

<sphqueries>

<sphinxql>SELECT id,gid,weight(),packedfactors() as my_weight FROM META:plain WHERE MATCH('Фичин баг') option ranker=expr('sum(exact_hit)');show meta</sphinxql>
<sphinxql>SELECT id,gid,weight() as my_weight FROM META:plain WHERE MATCH('Фичин баг') option ranker=sph04;show meta</sphinxql>
<sphinxql>SELECT id,gid,weight(),packedfactors() as my_weight FROM META:plain WHERE MATCH('^Фичин баг$') option ranker=expr('sum(exact_hit)');show meta</sphinxql>
<sphinxql>SELECT id,gid,weight() as my_weight FROM META:plain WHERE MATCH('^Фичин баг$') option ranker=sph04;show meta</sphinxql>
<sphinxql>SELECT id,gid,weight(),packedfactors() as my_weight FROM META:plain WHERE MATCH('"Фичин баг"') option ranker=expr('sum(exact_hit)');show meta</sphinxql>
<sphinxql>SELECT id,gid,weight() as my_weight FROM META:plain WHERE MATCH('"Фичин баг"') option ranker=sph04;show meta</sphinxql>
<sphinxql>SELECT id,gid,weight(),packedfactors() as my_weight FROM META:plain WHERE MATCH('english text') option ranker=expr('sum(exact_hit)');show meta</sphinxql>
<sphinxql>SELECT id,gid,weight() as my_weight FROM META:plain WHERE MATCH('english text') option ranker=sph04;show meta</sphinxql>
<sphinxql>SELECT id,gid,weight(),packedfactors() as my_weight FROM META:plain WHERE MATCH('"english text"') option ranker=expr('sum(exact_hit)');show meta</sphinxql>
<sphinxql>SELECT id,gid,weight() as my_weight FROM META:plain WHERE MATCH('"english text"') option ranker=sph04;show meta</sphinxql>
<sphinxql>SELECT id,gid,weight() as my_weight FROM META:plain WHERE MATCH('"Фичин баг"') option ranker=sph04;show meta</sphinxql>
<sphinxql>SELECT GROUPBY() FROM testw</sphinxql>

<!--regression lemmas at call keywords output -->
<sphinxql>INSERT INTO rt_ckw VALUES ( 1, 'фичин баг, но не фичина бага', 11 )</sphinxql>
<sphinxql>CALL KEYWORDS ( 'фичин баг', 'plain_ckw', 1 )</sphinxql>
<sphinxql>CALL KEYWORDS ( 'фичин баг', 'rt_ckw', 1 )</sphinxql>
<sphinxql>CALL KEYWORDS ( 'фичин баг', 'tmpl_ckw', 1 )</sphinxql>
<sphinxql>CALL KEYWORDS ( 'фичина бага', 'plain_ckw', 1 )</sphinxql>
<sphinxql>CALL KEYWORDS ( 'фичина бага', 'rt_ckw', 1 )</sphinxql>
<sphinxql>CALL KEYWORDS ( 'фичина бага', 'tmpl_ckw', 1 )</sphinxql>
<sphinxql>CALL KEYWORDS ( 'сталин жил', 'plain_ckw', 1 )</sphinxql>
<sphinxql>CALL KEYWORDS ( 'сталин жил', 'rt_ckw', 1 )</sphinxql>
<sphinxql>CALL KEYWORDS ( 'сталин жил', 'tmpl_ckw', 1 )</sphinxql>
<sphinxql>CALL KEYWORDS ( 'DovE', 'plain_ckw', 1 )</sphinxql>
<sphinxql>CALL KEYWORDS ( 'DovE', 'rt_ckw', 1 )</sphinxql>
<sphinxql>CALL KEYWORDS ( 'DovE', 'tmpl_ckw', 1 )</sphinxql>
<sphinxql>CALL KEYWORDS ( 'records recorded recording men man mans mens', 'plain_ckw', 1 )</sphinxql>
<sphinxql>CALL KEYWORDS ( 'records recorded recording men man mans mens', 'rt_ckw', 1 )</sphinxql>
<sphinxql>CALL KEYWORDS ( 'records recorded recording men man mans mens', 'tmpl_ckw', 1 )</sphinxql>

<!-- field-start, field-end escaping test -->
<sphinxql>SET profiling=1</sphinxql>
<sphinxql>SELECT id FROM testw WHERE MATCH('\\^one\\$') limit 1</sphinxql>
<sphinxql>SHOW PLAN</sphinxql>

</sphqueries>

</test>
