|
NAMESphinx::Config - Sphinx search engine configuration file read/modify/writeSYNOPSISuse Sphinx::Config; my $c = Sphinx::Config->new(); $c->parse($filename); $path = $c->get('index', 'test1', 'path'); $c->set('index', 'test1', 'path', $path); $c->save($filename); ... CONSTRUCTORnew$c = Sphinx::Config->new; preserve_inheritance$c->preserve_inheritance(0); $c->preserve_inheritance(1); $pi = $c->preserve_inheritance(1); Set/get the current behaviour for preserving inherited values. When set to a non-zero value (the default), if a value is set in a parent section, then it is automatically inherited by any child sections, and when the configuration file is saved, values that are implicit through inheritance are not shown. When set to zero, each section is considered standalone and a complete set of values is shown in the saved file. This flag may be enabled and disabled selectively for calls to set() and save(). METHODSparse$c->parse($filename) Parse the given Sphinx configuration file. Dies on errors. parse_string$c->parse_string( $string ); Parse the Sphinx configuration in the given string. Dies on errors. config$config = $c->config; Get the parsed configuration data as an array of hashes, where each entry in the array represents one section of the configuration, in the order as parsed or constructed. Each section is described by a hash with the following keys:
get$value = $c->get($type, $name, $varname) $value = $c->get($type, $name) Get the value of a configuration parameter. If $varname is specified, the value of the named parameter from the section identified by the type and name is returned as a scalar. Otherwise, the hash containing all key/value pairs from the section is returned. $name may be undef for sections that do not require a name (e.g. searchd, indexer, search). If the section cannot be found or the named parameter does not exist, undef is returned. set$c->set($type, $name, $varname, $value) $c->set($type, $name, \%values) $c->set($type, $name, undef(), $base_name) $c->set($type, $name, \%values, $base_name) Set the value or values of a section in the configuration. If varname is given, then the single parameter of that name in the given section is set to the specified value. If the value is an array, multiple entries will be created in the output file for the same key. If a hash of name/value pairs is given, then any existing values are replaced with the given hash. $c->set('source', , $name, \%values); If the section does not currently exist, a new one is appended. Set $name to "undef" to set variables in an "indexer", "searchd" or "search" section. $c->set('indexer', undef, 'listen', $port); $c->set('search', undef, \%values ); To change the section's inheritance, set $value to undef and specify a value in the 4th parameter. $c->set('source', 'src1', undef(), 'base2'); You this may be combined with a hash variable : $c->set('source', 'src1', \%values, 'base_source'); To delete a name/value pair, set $value to undef. $c->set('source', 'src1', 'sql_query_pre', undef()); $c->set('source', 'src1', 'sql_query_pre'); Returns the hash containing the current data values for the given section. See preserve_inheritance for a description of how inherited values are handled. save$c->save $c->save($filename, $comment) Save the configuration to a file. The currently opened file is used if not specified. The comment is inserted literally, so each line should begin with '#'. See preserve_inheritance for a description of how inherited blocks are handled. as_string$s = $c->as_string $s = $c->as_string($comment) Returns the configuration as a string, optionally with a comment prepended. The comment is inserted literally, so each line should begin with '#'. An effort has been made to make the configuration round-trip safe. That is, any formating or comments in the original should also appear as-is in the generated configuration. New sections are added at the end of the configuration with an 8 space indent. New variables added to existing sections are handled as follows:
as_string_new$s = $c->as_string_new $s = $c->as_string_new($comment) Returns the configuration as a string, optionally with a comment prepended, without attempting to preserve formatting from the original file. The comment is inserted literally, so each line should begin with '#'. SEE ALSOSphinx::SearchAUTHORJon Schutz, "<jon at jschutz.net>"BUGSPlease report any bugs or feature requests to "bug-sphinx-config at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Sphinx-Config>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.SUPPORTYou can find documentation for this module with the perldoc command.perldoc Sphinx::Config You can also look for information at:
ACKNOWLEDGEMENTSPhilip Gwyn contributed the patch to preserve round-trip formatting, which was a significant chunk of work.COPYRIGHT & LICENSECopyright 2007 Jon Schutz, all rights reserved.This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Visit the GSP FreeBSD Man Page Interface. |