NAME
Dezi::Doc - a Dezi client document
SYNOPSIS
# add doc to the index
use Dezi::Doc;
my $html = "<html>hello world</html>";
my $doc = Dezi::Doc->new(
mime_type => 'text/html',
uri => 'foo/bar.html',
mtime => time(),
size => length $html,
content => $html,
);
$client->index( $doc );
# construct a document with field/value pairs
my $doc2 = Dezi::Doc->new(
uri => 'auto/xml/magic',
);
$doc2->set_field('title' => 'ima dezi doc');
$doc2->set_field('body' => 'hello world!');
$client->index( $doc2 );
# search results are also Dezi::Doc objects
for my $doc (@{ $response->results }) {
printf("hit: %s %s\n", $doc->score, $doc->uri);
}
DESCRIPTION
Dezi::Doc represents one document in a collection.
METHODS
new
Create new object. Takes pairs of key/values where the keys are one of:
- mime_type
-
Sometimes known as the content type. A MIME type indicates the kind of document this is.
- uri
-
The unique URI for the document.
- mtime
-
Last modified time. Should be expressed in Epoch seconds.
- size
-
Length in bytes.
- content
-
The document's content.
score
When returned from a Dezi::Response->results array, the score attribute is the search ranking score.
title
When returned from a Dezi::Response->results array, the title is the document's parsed title.
NOTE you cannot set the title of a doc object when sending to the index. See set_field() instead.
summary
When returned from a Dezi::Response->results array, the summary is the snipped and highlighted extract from the document showing query terms in context.
NOTE you cannot set the summary of a doc object when sending to the index. The summary is a result field only. It typically represents all or snipped part of the swishdescription
field in the index.
as_string_ref
Returns a scalar ref pointing at the Dezi::Doc serialized, either the value of content() or a XML fragment representing values set with set_field().
get_field( field_name )
Returns the value of field_name.
set_field( field => value )
Set the value for field field.
This method also sets the mime_type() of the document object to 'application/xml' since that is how as_string_ref() will render the object.
AUTHOR
Peter Karman, <karman at cpan.org>
BUGS
Please report any bugs or feature requests to bug-dezi-client at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Dezi-Client. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Dezi::Client
You can also look for information at:
RT: CPAN's request tracker
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
COPYRIGHT & LICENSE
Copyright 2011 Peter Karman.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.