Data::SearchEngine - A role for search engine abstraction.


Data-SearchEngine documentation  | view source Contained in the Data-SearchEngine distribution.

Index


NAME

Top

Data::SearchEngine - A role for search engine abstraction.

SYNOPSIS

Top

  package Data::SearchEngine::MySearch;

  with 'Data::SearchEngine';

  sub search {
    my ($self, $query) = @_;

    # ... your internal search junk

    my $result = Data::SearchEngine::Results->new(
        query => $query,
        pager => # ... make a Data::Page
    );

    foreach my $hit (@hits) {
        $result->add(Data::SearchEngine::Item->new(
            values => {
                name => $hit->name,
                description => $hit->description
            },
            score => $hit->score
        ));
    }

    return $result;
  }

DESCRIPTION

Top

There are lots of search engine libraries. Each has a different interface. The goal of Data::SearchEngine is to provide a simple, extensive set of classes and roles that you can use to wrap a search implementation. The net result will be an easily swappable backend with a common set of features.

Step 1 - Extend the Query

If you have specific attributes that you need for your query, subclass the Data::SearchEngine::Query object and add the attributes. This part is optional.

Step 2 - Wrap a search implementation

Next use the Data::SearchEngine role in a class that wraps your search implementation. You can find an example in Data::SearchEngine::Results.

Step 3 - Profit!!!

!!!

DIGESTS

Top

Data::SearchEngine provides a Digestable trait that can be applied to attributes of Query. Attributes with this trait will be added to a base64 MD5 digest to produce a unique key identifying this query. You can then serialize the Result using MooseX::Storage and store it under the digest of the Query for caching.

AUTHOR

Top

Cory G Watson, <gphat at cpan.org>

COPYRIGHT & LICENSE

Top


Data-SearchEngine documentation  | view source Contained in the Data-SearchEngine distribution.