Data-SearchEngine-Solr

 view release on metacpan or  search on metacpan

lib/Data/SearchEngine/Solr.pm  view on Meta::CPAN

    $self->add(@_);
}

1;



=pod

=head1 NAME

Data::SearchEngine::Solr

=head1 VERSION

version 0.20

=head1 SYNOPSIS

  my $solr = Data::SearchEngine::Solr->new(
    url => 'http://localhost:8983/solr',
    options => {
        fq => 'category:Foo',
        facets => 'true'
    }
  );

  my $query = Data::SearchEngine::Query->new(
    count => 10,
    page => 1,
    query => 'ice cream',
  );

  my $results = $solr->search($query);

  foreach my $item ($results->items) {
    print $item->get_value('name')."\n";
  }

=head1 DESCRIPTION

Data::SearchEngine::Solr is a L<Data::SearchEngine> backend for the Solr
search server.

=head1 NAME

Data::SearchEngine::Solr - Data::SearchEngine backend for Solr

=head1 SOLR FEATURES

=head2 FILTERS

This module uses the values from Data::SearchEngine::Query's C<filters> to
populate the C<fq> parameter.  Before talking to Solr we iterate over the
filters and add the filter's value to C<fq>.

  $query->filters->{'last name watson'} = 'last_name:watson';

Will results in fq=name:watson.  Multiple filters will be appended.

=head2 FACETS

Facets may be enabled thusly:

  $solr->options->{facets} = 'true';
  $solr->options->{facet.field} = 'somefield';

You may also use other C<facet.*> parameters, as defined by Solr.

To access facet data, consult the documentation for
L<Data::SearchEngine::Results> and it's C<facets> method.

=head2 SPELLCHECK

Queries may be spellchecked using Solr's spellcheck component. If you supply
the correct parameters through the URL or to your URI handler then
Data::SearchEngine::Solr will see it in the results and populate the bits from
L<Data::SearchEngine::Results::Spellcheck>.  Note that some of the features
may not work properly unless C<spellcheck.extendedResults> is true in your
query.

=head1 ATTRIBUTES

=head2 options

HashRef that is passed to L<WebService::Solr>.  Please see the above
documentation on filters and facets before using this directly.

=head2 url

The URL at which to contact the Solr instance.

=head1 METHODS

=head2 add (\@items)

Adds a list of L<Data::SearchEngine::Item>s to the Solr index.  The Items
are converted into L<WebService::Solr::Document>s using the follow means:

=over 4

=item C<score> is used as the bonus.

=item C<id> is used as the document's id.

=item Multiple-value fields are broken up into multiple
L<WebService::Solr::Field> objects per L<WebService::Solr>'s convention.  This
is merely a formality, it has no real affect.

=back

=head2 optimize

Calls WebService::Solr's C<optimize> method.

=head2 remove

Deletes an item from the index.  A straight dispatch to L<WebService::Solr>'s
C<delete>.

=head2 remove_by_id



( run in 1.337 second using v1.01-cache-2.11-cpan-39bf76dae61 )