Interchange-Search-Solr
view release on metacpan or search on metacpan
lib/Interchange/Search/Solr.pm view on Meta::CPAN
The terms used for the current search.
=head2 search_structure
The perl data structure used for the current search. It's passed to
L<Webservice::Solr::Query> for stringification.
=head2 sorting
The field used to sort the result (optional and defaults to score, as
per Solr doc).
You can set it to a scalar with a field name or instead you can use
the L<SQL::Abstract> syntax (all the cases documented there are
supported). E.g.
$solr->sorting([{ -asc => 'created_date' }, {-desc => [qw/updated_date sku/] }]);
If you pass a reference, the C<sorting_direction> setting is ignored.
=head2 sorting_direction
The direction used by the sorting, when C<sorting> is specified and is a plain scalar.
Default to 'desc'.
=cut
has solr_url => (is => 'ro',
required => 1);
has input_encoding => (is => 'ro');
=head2 wild_matching
By default, a search term produce a query with a wildcard appended. So
searching for 1234 will query 1234*. With this option set to true, a
wildcard is prepended as well, querying for *1234* instead).
=cut
has wild_matching => (is => 'ro',
default => sub { 0 });
=head2 stop_words_langs
The languages for which we should build the stop word list. It
defaults to:
[ 'en' ]
New in 0.10. To revert to the old behaviour (no filtering of
stopwords), pass an empty arrayref.
=cut
has stop_words => (is => 'lazy', isa => HashRef);
has stop_words_langs => (is => 'ro', default => sub { [qw/en/ ] }, isa => ArrayRef);
sub _build_stop_words {
my $self = shift;
my @stopwords;
foreach my $lang (@{ $self->stop_words_langs }) {
if (my $stops = Lingua::StopWords::getStopWords($lang, 'UTF-8')) {
push @stopwords, keys %$stops;
}
}
my %out = map { $_ => 1 } @stopwords;
return \%out;
}
=head2 min_chars
Minimum characters for filtering the search terms. Default to 3.
New in 0.10. To revert to the old behaviour, set it to 0.
=head2 permit_empty_search
By default, empty searches are not executed. You can permit them
setting this accessor to 1. The module will reset it to 0 when the
search is executed.
=cut
has min_chars => (is => 'ro', isa => Int, default => sub { 3 });
has permit_empty_search => (is => 'rw', isa => Bool, default => sub { 0 });
has search_fields => (is => 'ro',
default => sub {
return [
qw/sku
name
description/
]
},
isa => sub { die unless ref($_[0]) eq 'ARRAY' });
has facets => (is => 'rw',
isa => sub { die "not an arrayref" unless ref($_[0]) eq 'ARRAY' },
default => sub {
return [qw/suchbegriffe manufacturer/];
});
has facet_ranges => (is => 'rw',
isa => sub {
die "not an arrayref" unless ref($_[0]) eq 'ARRAY';
foreach my $i (@{$_[0]}) {
die "Missing name in facet range definition" unless $i->{name};
}
},
default => sub { [] },
);
sub _facet_range_names {
return map { $_->{name} } @{ shift->facet_ranges };
}
( run in 2.365 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )