NAME
WebService::Solr::Tiny - Perl interface to Apache Solr
SYNOPSIS
use WebService::Solr::Tiny 'solr_escape';
my $solr = WebService::Solr::Tiny->new;
# Simple
$solr->search('foo');
# Complex
$solr->search(
'{!lucene q.op=AND df=text}myfield:foo +bar -baz',
debugQuery => 'true',
fl => 'id,name,price',
fq => [
'foo:"' . solr_escape($foo) . '"',
'popularity:[10 TO *]',
'section:0',
],
omitHeader => 'true',
rows => 20,
sort => 'inStock desc, price asc',
start => 10,
);
DESCRIPTION
WebService::Solr::Tiny is similar to, and inspired by WebService::Solr, but with an aim to be tinier.
FUNCTIONS
solr_escape
Exportable on request, solr_escape is a small utility subroutine for escaping characters that have meaning in Lucene query syntax.
METHODS
search
PERFORMANCE
One way to increase the performance of this module is to swap out the decoder. By default Solr returns JSON, therefore the fastest decoder for this would be JSON::XS. You can swap out JSON::PP for JSON::XS like so:
use JSON::XS ();
use WebService::Solr::Tiny;
my $solr = WebService::Solr::Tiny->new( decoder => \&JSON::XS::decode_json );
However it's possible to make Solr return a compact binary format known as JavaBin, to do so we send wt=javabin with each request. Couple that with the CPAN module JavaBin like so:
use JavaBin ();
use WebService::Solr::Tiny;
my $solr = WebService::Solr::Tiny->new(
decoder => \&JavaBin::from_javabin,
default_args => { wt => 'javabin' },
);
Both of these should be faster than the stock configuration, but require a C compiler and are generally not as portable, YMMV so benchmark first.
SEE ALSO
COPYRIGHT AND LICENSE
Copyright © 2015 by James Raspass
This is free software; you can redistribute it and/or modify it under the same terms as Perl itself.