1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
<?xml version="1.0" encoding="utf-8"?>
<test>
<name>snippets vs force_all_words</name>
<config>
indexer
{
mem_limit = 16M
}
searchd
{
<searchd_settings/>
}
source main
{
type = mysql
<sql_settings/>
sql_query = select 1 as id, 'body' as body;
}
index test_idx
{
source = main
path = <data_path/>/main
docinfo = extern
min_word_len = 1
}
</config>
<custom_test><![CDATA[
$docs = array
(
"this is my test text to be highlighted, and for the sake of the testing we need to pump its length somewhat",
"another test text to be highlighted, below limit",
"test number three, without phrase match",
"final test, not only without phrase match, but also above limit and with swapped phrase text test as well",
);
$words = "test text";
$index = "test_idx";
$opts = array
(
"before_match" => "<b>",
"after_match" => "</b>",
"chunk_separator" => " ... ",
"around" => 3
);
$results = array();
for ($limit = 4; $limit < 60; ++$limit )
foreach ( array(0,1) as $exact )
foreach ( array(0,1) as $force )
{
$opts["exact_phrase"] = $exact;
$opts["force_all_words"] = $force;
$opts["limit"] = $limit;
$rs["opts"]="phrase $exact, force $force, limit $limit";
$res = $client->BuildExcerpts ( $docs, $index, $words, $opts );
if ( !$res )
$rs["result"] = $client->GetLastError();
else
$rs["result"] = $res;
$results[] = $rs;
}
]]></custom_test>
</test>
|