Sphinx::XML::Pipe2 - generates xml to feed xmlpipe2 of Sphinx Search
version 0.002
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, i.e. 'size' lc($1), # 'type' do { local( @ARGV, $/ ) = $name; <> }, # then fields in declaration order, i.e. 'content' $File::Find::name # 'path' ); } }, @ARGV); print $p->xml;
Declare document attribute. $name and $type is mandatory.
Declare document field. $name is mandatory.
Add document. $id - must be integer, @attr and @field must be be in declaration order.
Returns XML data suitable for xmlpipe2 data source.
Returns XML::LibXML::Document
Experimental state
Sphinx Search xmlpipe2 data source
Yegor Korablev <egor@cpan.org>
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.
To install Sphinx::XML::Pipe2, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Sphinx::XML::Pipe2
CPAN shell
perl -MCPAN -e shell install Sphinx::XML::Pipe2
For more information on module installation, please visit the detailed CPAN module installation guide.