NAME

Sphinx::XML::Pipe2 - generates xml to feed xmlpipe2 of Sphinx Search

VERSION

version 0.001

METHODS

attr($name, $type, $bits, $default)

Declare document attribute. $name and $type is mandatory.

field($name, $attr)

Declare document field. $name is mandatory.

add($id, @attr, @field)

Add document. $id - must be integer, @attr and @field must be be in declaration order.

xml

Returns XML data suitable for xmlpipe2 data source.

process

Returns XML::LibXML::Document

NOTICE

Experimental state

SYNOPSIS Example script which creates XML data for Sphinx Search xmlpipe2 data source of some documents in directories specified as script arguments

 use v5.14;
 use Sphinx::XML::Pipe2;
 use File::Find;

 binmode STDIN, ":encoding(utf8)";  
 binmode STDOUT, ":encoding(utf8)"

 my $p = Sphinx::XML::Pipe2->new;
  
 $p->attr('size', 'int');
 $p->attr('type', 'str2ordinal');
 $p->field('content');
 $p->field('path');

 my $i = 0;
 find( sub {
    my $file = $_;
    if (-f -r $file && (my $size = -s $file) && $file =~ /\.(html?|txt|rtf)?$/i) {
        $p->add( 
            $i, # document id
            $size, # attributes in declaration order
            lc($1),
            do { local( @ARGV, $/ ) = $name; <> }, # fields in declaration order 
            $File::Find::name
        );
    }
}, @ARGV);

print $p->xml;

SEE ALSO

Sphinx Search xmlpipe2 data source

AUTHOR

Yegor Korablev <egor@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2011 by Yegor Korablev.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.