#!/usr/bin/perl use warnings; #use strict; use Plucene::Document; use Plucene::Document::Field; use Plucene::Index::Writer; use Plucene::Analysis::SimpleAnalyzer; use Plucene::QueryParser; use Plucene::Search::IndexSearcher; use Data::Dumper; my $content = join("",<DATA>); my $doc = Plucene::Document->new; $doc->add(Plucene::Document::Field->Text("content", $content)); my $writer = Plucene::Index::Writer->new("my_index", Plucene::Analysis::SimpleAnalyzer->new(), 1); $writer->add_document($doc); undef $writer; # close my @docs; my $parser = Plucene::QueryParser->new({ analyzer => Plucene::Analysis::SimpleAnalyzer->new(), default => "text" # Default field for non-specified q +ueries }); my $query = $parser->parse('content:Craigslist appears to have surrend +ered'); my $searcher = Plucene::Search::IndexSearcher->new("my_index"); my $hc = Plucene::Search::HitCollector->new(collect => sub { my ($self, $doc, $score) = @_; push @docs, $searcher->doc($doc); }); $searcher->search_hc($query, $hc); print Dumper @docs;
As you can see I print the docs array, but this array doesn't contain the matching strings
In reply to Re^2: Get matching strings by searching with PLucene
by explodec14
in thread Get matching strings by searching with PLucene
by explodec14
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |