Plucene::Plugin::WeightedQueryParser - Specify weights for unqualified terms
use Plucene::Plugin::WeightedQueryParser; my $parser = Plucene::WeightedQueryParser->new({ analyzer => Plucene::Plugin::Analyzer::PorterAnalyzer->new(), weights => { title => 5, subtitle => 2, body => 1 } }); $parser->parse($q);
Quite often, you want unqualified search terms (hello) to search in either the title, the body or some other part of you document. The usual way to do this is to create another field, content, and throw everything in that, then make that the default field for unqualified terms.
hello
content
That's fine, until you want to add different weighting for terms - so terms found in the title of a document come first, then those in the subtitle, then the body of the document.
This module automatically remaps unqualified search terms, such as hello to (title:hello^5 OR subtitle:hello^2 OR body:hello^1), based on the weights passed in to the constructor.
(title:hello^5 OR subtitle:hello^2 OR body:hello^1)
Simon Cozens, simon@cpan.org
simon@cpan.org
Development of this module was made possible by the generous sponsorship of Text Matters, http://www.textmatters.com/
This module may be distributed under the same terms as Plucene itself.
perl.
To install Plucene::Plugin::WeightedQueryParser, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Plucene::Plugin::WeightedQueryParser
CPAN shell
perl -MCPAN -e shell install Plucene::Plugin::WeightedQueryParser
For more information on module installation, please visit the detailed CPAN module installation guide.