[libsphinx-search-perl] 12/16: New upstream release

Taku YASUI tach at debian.org
Sun Aug 11 11:53:24 UTC 2013


This is an automated email from the git hooks/post-receive script.

tach pushed a commit to branch master
in repository libsphinx-search-perl.

commit d0a947704d11d37c96f552f80a89f4623ff2523d
Author: tach <tach at 19660600-52fe-0310-9875-adc0d7a7b53c>
Date:   Sat Feb 19 01:33:36 2011 +0000

    New upstream release
---
 Changes              |   15 ++++++
 MANIFEST             |    1 +
 META.yml             |   54 ++++++++++++---------
 debian/changelog     |    6 +++
 lib/Sphinx/Search.pm |  127 +++++++++++++++++++++++++++++++++++++++-----------
 t/search.t           |    3 +-
 t/stringattr.t       |   12 +++++
 t/testlib/TestDB.pm  |   27 +++++------
 8 files changed, 182 insertions(+), 63 deletions(-)

diff --git a/Changes b/Changes
index 86b8bc7..d803ef3 100644
--- a/Changes
+++ b/Changes
@@ -78,3 +78,18 @@ Revision history for Sphinx-Search
 0.22    2009-05-07 
      	Moved use of Config variables out of new so Config is only accessed at startup, to avoid delays in
 	new(). (rt.cpan.org #45789)
+
+0.23_02 2010-04-04
+	Updated for compatibility with svn-r2269.
+	rt.cpan.org #54698 - doc fix
+	rt.cpan.org #56406 - string attributes
+
+0.23_03 2010-05-06
+	rt.cpan.org #57171 - fixed occasional warnings due to uninitialised
+	values
+
+0.24	2010-12-07
+	Updated for compatibility with 1.10-beta (svn-r2420)
+
+0.24.1  2010-12-16
+	rt.cpan.org #63945 - fixed missing constants
\ No newline at end of file
diff --git a/MANIFEST b/MANIFEST
index 6ef649a..64e6b42 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -12,5 +12,6 @@ t/pod-coverage.t
 t/pod.t
 t/search.t
 t/setserver.t
+t/stringattr.t
 t/testlib/TestDB.pm
 
diff --git a/META.yml b/META.yml
index 0c32417..917a292 100644
--- a/META.yml
+++ b/META.yml
@@ -1,26 +1,34 @@
 --- #YAML:1.0
-name:                Sphinx-Search
-version:             0.22
-abstract:            Sphinx search engine API Perl client
-license:             ~
-author:              
+name:               Sphinx-Search
+version:            0.240.1
+abstract:           Sphinx search engine API Perl client
+author:
     - Jon Schutz <jon at jschutz.net>
-generated_by:        ExtUtils::MakeMaker version 6.42
-distribution_type:   module
-requires:     
-    Carp:                          0
-    Class::Accessor::Fast:         0
-    Config:                        0
-    Data::Dumper:                  0
-    DBI:                           0
-    Encode:                        0
-    Errno:                         0
-    Fcntl:                         0
-    File::SearchPath:              0
-    Math::BigInt:                  0
-    Path::Class:                   0
-    Socket:                        0
-    Test::More:                    0
+license:            unknown
+distribution_type:  module
+configure_requires:
+    ExtUtils::MakeMaker:  0
+build_requires:
+    ExtUtils::MakeMaker:  0
+requires:
+    Carp:                 0
+    Class::Accessor::Fast:  0
+    Config:               0
+    Data::Dumper:         0
+    DBI:                  0
+    Encode:               0
+    Errno:                0
+    Fcntl:                0
+    File::SearchPath:     0
+    Math::BigInt:         0
+    Path::Class:          0
+    Socket:               0
+    Test::More:           0
+no_index:
+    directory:
+        - t
+        - inc
+generated_by:       ExtUtils::MakeMaker version 6.56
 meta-spec:
-    url:     http://module-build.sourceforge.net/META-spec-v1.3.html
-    version: 1.3
+    url:      http://module-build.sourceforge.net/META-spec-v1.4.html
+    version:  1.4
diff --git a/debian/changelog b/debian/changelog
index 7311431..b4618ea 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+libsphinx-search-perl (0.240.1-1) UNRELEASED; urgency=low
+
+  * New upstream release
+
+ -- Taku YASUI <tach at debian.org>  Sat, 19 Feb 2011 10:33:06 +0900
+
 libsphinx-search-perl (0.22-1) unstable; urgency=low
 
   * New upstream release
diff --git a/lib/Sphinx/Search.pm b/lib/Sphinx/Search.pm
index 10d4ec5..be3c4a7 100644
--- a/lib/Sphinx/Search.pm
+++ b/lib/Sphinx/Search.pm
@@ -24,6 +24,10 @@ Sphinx::Search - Sphinx search engine API Perl client
 
 Please note that you *MUST* install a version which is compatible with your version of Sphinx.
 
+Use version 0.240.1 for Sphinx-1.10-beta (svn-2420)
+
+Use version 0.23_02 for Sphinx svn-2269 (experimental)
+
 Use version 0.22 for Sphinx 0.9.9-rc2 and later (Please read the Compatibility Note under L<SetEncoders> regarding encoding changes)
 
 Use version 0.15 for Sphinx 0.9.9-svn-r1674
@@ -46,17 +50,17 @@ Use version 0.02 for Sphinx 0.9.8-cvs-20070818
 
 =cut
 
-our $VERSION = '0.22';
+our $VERSION = '0.240.1';
 
 =head1 SYNOPSIS
 
     use Sphinx::Search;
 
-    $sphinx = Sphinx::Search->new();
+    $sph = Sphinx::Search->new();
 
-    $results = $sphinx->SetMatchMode(SPH_MATCH_ALL)
-                      ->SetSortMode(SPH_SORT_RELEVANCE)
-                      ->Query("search terms");
+    $results = $sph->SetMatchMode(SPH_MATCH_ALL)
+                   ->SetSortMode(SPH_SORT_RELEVANCE)
+                   ->Query("search terms");
 
 =head1 DESCRIPTION
 
@@ -70,10 +74,14 @@ our @EXPORT = qw(
 		SPH_MATCH_ALL SPH_MATCH_ANY SPH_MATCH_PHRASE SPH_MATCH_BOOLEAN SPH_MATCH_EXTENDED
 		SPH_MATCH_FULLSCAN SPH_MATCH_EXTENDED2
 		SPH_RANK_PROXIMITY_BM25 SPH_RANK_BM25 SPH_RANK_NONE SPH_RANK_WORDCOUNT
+                SPH_RANK_PROXIMITY SPH_RANK_MATCHANY SPH_RANK_FIELDMASK SPH_RANK_SPH04 
+                SPH_RANK_TOTAL
 		SPH_SORT_RELEVANCE SPH_SORT_ATTR_DESC SPH_SORT_ATTR_ASC SPH_SORT_TIME_SEGMENTS
 		SPH_SORT_EXTENDED SPH_SORT_EXPR
 		SPH_GROUPBY_DAY SPH_GROUPBY_WEEK SPH_GROUPBY_MONTH SPH_GROUPBY_YEAR SPH_GROUPBY_ATTR
 		SPH_GROUPBY_ATTRPAIR
+                SPH_ATTR_INTEGER SPH_ATTR_TIMESTAMP SPH_ATTR_ORDINAL SPH_ATTR_BOOL
+                SPH_ATTR_FLOAT SPH_ATTR_BIGINT SPH_ATTR_STRING SPH_ATTR_MULTI
 		);
 
 # known searchd commands
@@ -83,13 +91,16 @@ use constant SEARCHD_COMMAND_UPDATE	=> 2;
 use constant SEARCHD_COMMAND_KEYWORDS	=> 3;
 use constant SEARCHD_COMMAND_PERSIST	=> 4;
 use constant SEARCHD_COMMAND_STATUS	=> 5;
+use constant SEARCHD_COMMAND_QUERY	=> 6;
+use constant SEARCHD_COMMAND_FLUSHATTRS	=> 7;
 
 # current client-side command implementation versions
-use constant VER_COMMAND_SEARCH		=> 0x116;
-use constant VER_COMMAND_EXCERPT	=> 0x100;
+use constant VER_COMMAND_SEARCH		=> 0x117;
+use constant VER_COMMAND_EXCERPT	=> 0x102;
 use constant VER_COMMAND_UPDATE	        => 0x102;
 use constant VER_COMMAND_KEYWORDS       => 0x100;
 use constant VER_COMMAND_STATUS         => 0x100;
+use constant VER_COMMAND_FLUSHATTRS     => 0x100;
 
 # known searchd status codes
 use constant SEARCHD_OK			=> 0;
@@ -113,6 +124,9 @@ use constant SPH_RANK_NONE              => 2; # no ranking, all matches get a we
 use constant SPH_RANK_WORDCOUNT         => 3; # simple word-count weighting, rank is a weighted sum of per-field keyword occurence counts
 use constant SPH_RANK_PROXIMITY         => 4;
 use constant SPH_RANK_MATCHANY          => 5;
+use constant SPH_RANK_FIELDMASK         => 6;
+use constant SPH_RANK_SPH04             => 7;
+use constant SPH_RANK_TOTAL             => 8;
 
 # known sort modes
 use constant SPH_SORT_RELEVANCE		=> 0;
@@ -134,6 +148,7 @@ use constant SPH_ATTR_ORDINAL		=> 3;
 use constant SPH_ATTR_BOOL		=> 4;
 use constant SPH_ATTR_FLOAT		=> 5;
 use constant SPH_ATTR_BIGINT		=> 6;
+use constant SPH_ATTR_STRING		=> 7;
 use constant SPH_ATTR_MULTI		=> 0x40000000;
 
 # known grouping functions
@@ -261,7 +276,7 @@ sub new {
     my $self = {
 	# per=client-object settings
 	_host		=> 'localhost',
-	_port		=> 3312,
+	_port		=> 9312,
 	_path           => undef,
 	_socket         => undef,
 
@@ -427,7 +442,7 @@ sub SetEncoders {
     $sph->SetServer($path, $port);
 
 In the first form, sets the host (string) and port (integer) details for the
-searchd server using a network (INET) socket.
+searchd server using a network (INET) socket (default is localhost:9312).
 
 In the second form, where $path is a local filesystem path (optionally prefixed
 by 'unix://'), sets the client to access the searchd server via a local (UNIX
@@ -493,7 +508,12 @@ sub _Send {
 sub _Connect {
 	my $self = shift;
 	
-	return $self->{_socket} if $self->{_socket};
+	if ($self->{_socket}) {
+	    # persistent connection, check it
+	    return $self->{_socket} if $self->{_socket}->connected;
+	    # force reopen
+	    undef $self->{_socket};
+	}
 
 	my $debug = $self->{_debug};
 	my $str_dest = $self->{_path} ? 'unix://' . $self->{_path} : "$self->{_host}:$self->{_port}";
@@ -565,6 +585,11 @@ sub _GetResponse {
 	};
 
 	my ($status, $ver, $len ) = unpack("n2N", $header);
+	if ( ! defined($len) ) {
+	    $self->_Error("read failed: $!");
+	    return 0;
+	}
+
         my $response = q{};
 	my $lasterror = q{};
 	my $lentotal = 0;
@@ -745,11 +770,8 @@ sub SetRankingMode {
     my $self = shift;
     my $ranker = shift;
 
-    croak("Unknown ranking mode: $ranker") unless ( $ranker==SPH_RANK_PROXIMITY_BM25
-						    || $ranker==SPH_RANK_BM25
-						    || $ranker==SPH_RANK_NONE
-						    || $ranker==SPH_RANK_WORDCOUNT
-						    || $ranker==SPH_RANK_PROXIMITY );
+    croak("Unknown ranking mode: $ranker") unless ( $ranker >= 0
+						    && $ranker < SPH_RANK_TOTAL );
 
     $self->{_ranker} = $ranker;
     return $self;
@@ -909,7 +931,7 @@ sub SetIDRange {
     $sph->SetFilter($attr, \@values, $exclude);
 
 Sets the results to be filtered on the given attribute.  Only results which have
-attributes matching the given (numeric) values will be returned.
+attributes matching the given values will be returned.
 
 This may be called multiple times with different attributes to select on
 multiple attributes.
@@ -927,9 +949,6 @@ sub SetFilter {
     croak("values is not an array reference") unless (ref($values) eq 'ARRAY');
     croak("values reference is empty") unless (scalar(@$values));
 
-    foreach my $value (@$values) {
-	croak("value $value is not numeric") unless ($value =~ m/$num_re/);
-    }
     push(@{$self->{_filters}}, {
 	type => SPH_FILTER_VALUES,
 	attr => $attribute,
@@ -1602,6 +1621,10 @@ sub RunQueries {
 			push(@{$data->{$attr}}, $val);
 		    }
 		}
+		elsif ($attrs{$attr} == SPH_ATTR_STRING) {
+		    $data->{$attr} = $self->{_string_decoder}->(substr ($response, $p, $val));
+		    $p += $val;
+		}
 		else {
 		    $data->{$attr} = $val;
 		}
@@ -1666,6 +1689,10 @@ A hash which contains additional optional highlighting parameters:
 
 =item limit - max excerpt size in symbols (codepoints), default is 256
 
+=item limit_passages - Limits the maximum number of passages that can be included into the snippet. Integer, default is 0 (no limit).
+
+=item limit_words - Limits the maximum number of keywords that can be included into the snippet. Integer, default is 0 (no limit). 
+
 =item around - how many words to highlight around each match, default is 5
 
 =item exact_phrase - whether to highlight exact phrase matches only, default is false
@@ -1674,7 +1701,19 @@ A hash which contains additional optional highlighting parameters:
 
 =item use_boundaries
 
-=item weight_order 
+=item weight_order - Whether to sort the extracted passages in order of relevance (decreasing weight), or in order of appearance in the document (increasing position). Boolean, default is false.
+
+=item query_mode - Whether to handle $words as a query in extended syntax, or as a bag of words (default behavior). For instance, in query mode ("one two" | "three four") will only highlight and include those occurrences "one two" or "three four" when the two words from each pair are adjacent to each other. In default mode, any single occurrence of "one", "two", "three", or "four" would be highlighted. Boolean, default is false. 
+
+=item force_all_words - Ignores the snippet length limit until it includes all the keywords. Boolean, default is false. 
+
+=item start_passage_id - Specifies the starting value of %PASSAGE_ID% macro (that gets detected and expanded in before_match, after_match strings). Integer, default is 1. 
+
+=item load_files - Whether to handle $docs as data to extract snippets from (default behavior), or to treat it as file names, and load data from specified files on the server side. Boolean, default is false. 
+
+=item html_strip_mode - HTML stripping mode setting. Defaults to "index", which means that index settings will be used. The other values are "none" and "strip", that forcibly skip or apply stripping irregardless of index settings; and "retain", that retains HTML markup and protects it from highlighting. The "retain" mode can only be used when highlighting full documents and thus requires that no snippet size limits are set. String, allowed values are "none", "strip", "index", and "retain".
+
+=item allow_empty - Allows empty string to be returned as highlighting result when a snippet could not be generated (no keywords match, or no passages fit the limit). By default, the beginning of original text would be returned instead of an empty string. Boolean, default is false. 
 
 =back
 
@@ -1703,23 +1742,35 @@ sub BuildExcerpts {
 	$opts->{"after_match"} ||= "</b>";
 	$opts->{"chunk_separator"} ||= " ... ";
 	$opts->{"limit"} ||= 256;
+	$opts->{"limit_passages"} ||= 0;
+	$opts->{"limit_words"} ||= 0;
 	$opts->{"around"} ||= 5;
 	$opts->{"exact_phrase"} ||= 0;
 	$opts->{"single_passage"} ||= 0;
 	$opts->{"use_boundaries"} ||= 0;
 	$opts->{"weight_order"} ||= 0;
+	$opts->{"query_mode"} ||= 0;
+	$opts->{"force_all_words"} ||= 0;
+	$opts->{"start_passage_id"} ||= 1;
+	$opts->{"load_files"} ||= 0;
+	$opts->{"html_strip_mode"} ||= "index";
+	$opts->{"allow_empty"} ||= 0;
 
 	##################
 	# build request
 	##################
 
-	# v.1.0 req
+	# v.1.2 req
 	my $req;
 	my $flags = 1; # remove spaces
 	$flags |= 2 if ( $opts->{"exact_phrase"} );
 	$flags |= 4 if ( $opts->{"single_passage"} );
 	$flags |= 8 if ( $opts->{"use_boundaries"} );
 	$flags |= 16 if ( $opts->{"weight_order"} );
+	$flags |= 32 if ( $opts->{"query_mode"} );
+	$flags |= 64 if ( $opts->{"force_all_words"} );
+	$flags |= 128 if ( $opts->{"load_files"} );
+	$flags |= 256 if ( $opts->{"allow_empty"} );
 	$req = pack ( "NN", 0, $flags ); # mode=0, flags=$flags
 
 	$req .= pack ( "N/a*", $index ); # req index
@@ -1729,8 +1780,11 @@ sub BuildExcerpts {
 	$req .= pack ( "N/a*", $opts->{"before_match"});
 	$req .= pack ( "N/a*", $opts->{"after_match"});
 	$req .= pack ( "N/a*", $opts->{"chunk_separator"});
-	$req .= pack ( "N", int($opts->{"limit"}) );
-	$req .= pack ( "N", int($opts->{"around"}) );
+	$req .= pack ( "NN", int($opts->{"limit"}), int($opts->{"around"}) );
+	$req .= pack ( "NNN", int($opts->{"limit_passages"}), 
+		       int($opts->{"limit_words"}), 
+		       int($opts->{"start_passage_id"}) ); # v1.2
+	$req .= pack ( "N/a*", $opts->{"html_strip_mode"});
 
 	# documents
 	$req .= pack ( "N", scalar(@$docs) );
@@ -1746,9 +1800,7 @@ sub BuildExcerpts {
 	$req = pack ( "nnN/a*", SEARCHD_COMMAND_EXCERPT, VER_COMMAND_EXCERPT, $req); # add header
 	$self->_Send($fp, $req);
 	
-	my $response = $self->_GetResponse($fp, VER_COMMAND_EXCERPT);
-	return unless $response;
-
+	my $response = $self->_GetResponse($fp, VER_COMMAND_EXCERPT) or return;
 	my ($pos, $i) = 0;
 	my $res = [];	# Empty hash ref
         my $rlen = length($response);
@@ -2063,6 +2115,29 @@ sub Status {
     return \%res;
 }
     
+=head2 FlushAttributes
+
+=cut
+
+sub FlushAttributes {
+    my $self = shift;
+
+    my $fp = $self->_Connect() or return;
+    
+    my $req = pack("nnN", SEARCHD_COMMAND_FLUSHATTRS, VER_COMMAND_FLUSHATTRS, 0 ); # len=0
+    $self->_Send($fp, $req) or return;
+    my $response = $self->_GetResponse ( $fp, VER_COMMAND_FLUSHATTRS );
+    return unless $response;
+    
+    my $tag = -1;
+    if (length($response) == 4) {
+	$tag = unpack ( "N*", substr ( $response, 0, 4 ) );
+    }
+    else {
+	$self->_Error("unexpected response length");
+    }
+    return $tag;
+}    
 
 =head1 SEE ALSO
 
diff --git a/t/search.t b/t/search.t
index cee371f..8f41e95 100644
--- a/t/search.t
+++ b/t/search.t
@@ -63,6 +63,7 @@ sub run_all_tests {
 # Basic test on 'a'
 my $results = $sphinx->Query("a");
 ok($results, "Results for 'a'");
+
 print $sphinx->GetLastError unless $results;
 ok($results->{total_found} == 4, "total_found for 'a'");
 ok($results->{total} == 4, "total for 'a'");
@@ -76,7 +77,7 @@ is_deeply($results->{'words'},
 	  },
 	  "words for 'a'");
 is_deeply($results->{'fields'}, [ qw/field1 field2/ ], "fields for 'a'");
-is_deeply($results->{'attrs'}, { attr1 => 1, lat => 5, long => 5 }, "attributes for 'a'");
+is_deeply($results->{'attrs'}, { attr1 => 1, lat => 5, long => 5, stringattr => 7 }, "attributes for 'a'");
 my $weights = 1;
 $weights *= $_->{weight} for @{$results->{matches}};
 ok($weights == 1, "weights for 'a'");
diff --git a/t/stringattr.t b/t/stringattr.t
new file mode 100644
index 0000000..b14e511
--- /dev/null
+++ b/t/stringattr.t
@@ -0,0 +1,12 @@
+#! /usr/bin/perl
+
+use Test::More tests => 1;
+
+use Sphinx::Search; 
+
+my $sphinx = Sphinx::Search->new(); 
+eval {
+  my $r = $sphinx->SetFilter('mystring', ['4bb4afe18d9c4e550798b543']);
+};
+ok(! $@, "string attribute filtering");
+
diff --git a/t/testlib/TestDB.pm b/t/testlib/TestDB.pm
index de156dd..8573900 100644
--- a/t/testlib/TestDB.pm
+++ b/t/testlib/TestDB.pm
@@ -2,11 +2,6 @@ package TestDB;
 
 use strict;
 use warnings;
-
-package TestDB;
-
-use strict;
-use warnings;
 use base qw(Class::Accessor::Fast);
 use DBI;
 use File::SearchPath qw/searchpath/;
@@ -117,15 +112,16 @@ sub create_db {
 				             \`attr1\` INT NOT NULL,
 				             \`lat\` FLOAT NOT NULL,
 				             \`long\` FLOAT NOT NULL,
+				             \`stringattr\` VARCHAR(100),
 					     PRIMARY KEY (\`id\`)) DEFAULT CHARSET=utf8 COLLATE=utf8_bin });
-    $dbi->do(qq{INSERT INTO \`$dbtable\` (\`id\`,\`field1\`,\`field2\`,\`attr1\`,\`lat\`,\`long\`) VALUES
-		   (1, 'a', 'bb', 2, 0.35, 0.70),
-		   (2, 'a', 'bb ccc', 4, 0.70, 0.35),
-		   (3, 'a', 'bb ccc dddd', 1, 0.35, 0.70),
-		   (4, 'a bb', 'bb ccc dddd', 5, 0.35, 0.70),
-		   (5, 'bb', 'bb bb ccc dddd', 3, 1.5, 1.5),
-		   ('9223372036854775807', 'xx', 'xx', 9000, 150, 150),
-                   (6, "\x{65e5}\x{672c}\x{8a9e}", '', 0, 0, 0)
+    $dbi->do(qq{INSERT INTO \`$dbtable\` (\`id\`,\`field1\`,\`field2\`,\`attr1\`,\`lat\`,\`long\`,\`stringattr\`) VALUES
+		   (1, 'a', 'bb', 2, 0.35, 0.70, ''),
+		   (2, 'a', 'bb ccc', 4, 0.70, 0.35, ''),
+		   (3, 'a', 'bb ccc dddd', 1, 0.35, 0.70, ''),
+		   (4, 'a bb', 'bb ccc dddd', 5, 0.35, 0.70, ''),
+		   (5, 'bb', 'bb bb ccc dddd', 3, 1.5, 1.5, 'new string attribute'),
+		   ('9223372036854775807', 'xx', 'xx', 9000, 150, 150, ''),
+                   (6, "\x{65e5}\x{672c}\x{8a9e}", '', 0, 0, 0, '')
 		});
     };
     if ($@) {
@@ -167,6 +163,7 @@ sub write_config {
 	sql_attr_uint = attr1
 	sql_attr_float = lat
 	sql_attr_float = long
+        sql_attr_string = stringattr
     }
     index test_jjs_index {
 	source = test_jjs_src
@@ -218,6 +215,10 @@ sub run_searchd {
     my $searchd = $self->searchd;
 
     my ($pid) = _run_forks(sub {
+#	open STDOUT, '>&STDERR';
+	open STDIN, '/dev/null';
+	open STDOUT, '>/dev/null';
+	open STDERR, '>&STDOUT';
 	exec("$searchd --config $configfile");
     });
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libsphinx-search-perl.git



More information about the Pkg-perl-cvs-commits mailing list