File: test2.php

package info (click to toggle)
sphinxsearch 2.2.11-8
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 25,720 kB
  • sloc: cpp: 102,259; xml: 85,608; sh: 9,259; php: 3,790; ansic: 3,158; yacc: 1,969; java: 1,336; ruby: 1,289; python: 1,062; pascal: 912; perl: 381; lex: 275; makefile: 150; sql: 77; cs: 35
file content (53 lines) | stat: -rw-r--r-- 965 bytes parent folder | download | duplicates (4)
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
<?php

//
// $Id$
//

require ( "sphinxapi.php" );

$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 = "test1";
$opts = array
(
	"before_match"		=> "<b>",
	"after_match"		=> "</b>",
	"chunk_separator"	=> " ... ",
	"limit"				=> 60,
	"around"			=> 3,
);

foreach ( array(0,1) as $exact )
{
	$opts["exact_phrase"] = $exact;
	print "exact_phrase=$exact\n";

	$cl = new SphinxClient ();
	$res = $cl->BuildExcerpts ( $docs, $index, $words, $opts );
	if ( !$res )
	{
		die ( "ERROR: " . $cl->GetLastError() . ".\n" );
	} else
	{
		$n = 0;
		foreach ( $res as $entry )
		{
			$n++;
			print "n=$n, res=$entry\n";
		}
		print "\n";
	}
}

//
// $Id$
//

?>