[KinoSearch] KSx::Search::LongFieldSim in revision 3811
Henka
henka at cityweb.co.za
Fri Sep 5 07:16:27 PDT 2008
argh, I wasn't paying attention, here's the svn diff:
Index: sample/conf.pl
===================================================================
--- sample/conf.pl (revision 3813)
+++ sample/conf.pl (working copy)
@@ -11,5 +11,5 @@
# File system path to the directory which holds the US Constitution html
# files.
- uscon_source => 'sample/us_constitution',
+ uscon_source => 'us_constitution',
};
\ No newline at end of file
Index: sample/USConSchema.pm
===================================================================
--- sample/USConSchema.pm (revision 3813)
+++ sample/USConSchema.pm (working copy)
@@ -13,11 +13,18 @@
use base 'KinoSearch::Schema';
use KinoSearch::Analysis::PolyAnalyzer;
+package USConSchema::testfield;
+use base 'KinoSearch::FieldSpec::text';
+use KSx::Search::LongFieldSim;
+sub similarity { KSx::Search::LongFieldSim->new }
+
+
our %fields = (
- title => 'text',
- content => 'text',
- url => 'USConSchema::NotIndexed',
- category => 'USConSchema::NotAnalyzed',
+ title => 'text',
+ content => 'text',
+ url => 'USConSchema::NotIndexed',
+ category => 'USConSchema::NotAnalyzed',
+ testfield => 'USConSchema::testfield',
);
sub analyzer {
Index: sample/invindexer.pl
===================================================================
--- sample/invindexer.pl (revision 3813)
+++ sample/invindexer.pl (working copy)
@@ -4,7 +4,7 @@
# Load configuration file. (Note: change conf.pl location as needed.)
my $conf;
-BEGIN { $conf = do "sample/conf.pl" or die "Can't locate conf.pl"; }
+BEGIN { $conf = do "./conf.pl" or die "Can't locate conf.pl"; }
use lib @{ $conf->{lib} };
use File::Spec::Functions qw( catfile );
@@ -49,10 +49,10 @@
: $filename =~ /preamble/ ? 'preamble'
: die "Can't derive category for $filename";
return {
- title => $title_node->as_trimmed_text,
- content => $bodytext_node->as_trimmed_text,
- url => "/us_constitution/$filename",
- category => $category,
+ title => $title_node->as_trimmed_text,
+ content => $bodytext_node->as_trimmed_text,
+ testfield => $bodytext_node->as_trimmed_text,
+ url => "/us_constitution/$filename",
+ category => $category,
};
}
-
Index: sample/search.cgi
===================================================================
--- sample/search.cgi (revision 3813)
+++ sample/search.cgi (working copy)
@@ -1,12 +1,13 @@
-#!/usr/bin/perl -T
+#!/usr/bin/perl
use strict;
use warnings;
# Load configuration file. (Note: change conf.pl location as needed.)
-my $conf;
-BEGIN { $conf = do "./conf.pl" or die "Can't locate conf.pl"; }
-
-use lib @{ $conf->{lib} };
+#my $conf;
+#BEGIN { $conf = do "/www/sites/testsite/htdocs/test/sample/conf.pl"
or die "Can't locate conf.pl"; }
+#
+use lib '/www/sites/testsite/htdocs/testing/sample-longfield-sim';
+#use lib @{ $conf->{lib} };
use CGI;
use Data::Pageset;
use HTML::Entities qw( encode_entities );
@@ -21,7 +22,7 @@
# Create a Searcher object and feed it a query.
my $searcher = KinoSearch::Searcher->new(
- invindex => USConSchema->open( $conf->{path_to_invindex} ) );
+ invindex => USConSchema->open(
'/www/sites/testsite/htdocs/testing/sample-longfield-sim/uscon_invindex' )
);
my $hits = $searcher->search(
query => $q,
offset => $offset,
More information about the kinosearch
mailing list