Skip to main content.
home | support | download

Back to List Archive

[swish-e] ANNOUNCE: Dezi and Dezi::Client

From: at <Peter>
Date: Fri, 30 Sep 2011 09:31:14 -0500
Initial releases of Dezi and Dezi::Client are now on CPAN:

https://metacpan.org/module/Dezi
https://metacpan.org/module/Dezi::Client

Dezi is a search platform built on Swish3, Apache Lucy, Search::OpenSearch and
Plack. Dezi provides a RESTful HTTP interface to Lucy indexes.

>From the SYNOPSIS:

Start the Dezi server, listening on port 5000:

 % dezi -p 5000

Add a document to the index:

 % curl http://localhost:5000/index/foo -XPOST \
   -d '<doc><title>bar</title>hello world</doc>' \
   -H 'Content-Type: application/xml'

Search the index:

 % curl 'http://localhost:5000/search?q=bar'

Or instead of curl one-liners, use the Dezi::Client:

use Dezi::Client;

# open a connection
my $client = Dezi::Client->new(
   server  => 'http://localhost:5000',
);

# add/update a filesystem document to the index
$client->index( 'path/to/file.html' );

# add/update an in-memory document to the index
$client->index( \$html_doc, uri => 'foo/bar.html' );

# add/update a Dezi::Doc to the index
$client->index( $dezi_doc );

# remove a document from the index
$client->delete( '/doc/uri/relative/to/index' );

# search the index
my $response = $client->search( q => 'foo' );

# iterate over results
for my $result ((at)not-real.{ $response->results }) {
    printf("--\n uri: %s\n title: %s\n score: %s\n",
       $result->uri, $result->title, $result->score);
}

# print stats
printf("       hits: %d\n", $response->total);
printf("search time: %s\n", $response->search_time);
printf(" build time: %s\n", $response->build_time);
printf("      query: %s\n", $response->query);

-- 
Peter Karman  .  http://peknet.com/  .  peter(at)not-real.peknet.com
_______________________________________________
Users mailing list
Users(at)not-real.lists.swish-e.org
http://lists.swish-e.org/listinfo/users
Received on Fri Sep 30 2011 - 14:31:17 GMT