.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.14 .\" .\" Standard preamble: .\" ======================================================================== .de Sh \" Subsection heading .br .if t .Sp .ne 5 .PP \fB\\$1\fR .PP .. .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. | will give a .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' .\" expand to `' in nroff, nothing in troff, for use with C<>. .tr \(*W-|\(bv\*(Tr .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' 'br\} .\" .\" If the F register is turned on, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .\" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .hy 0 .if n .na .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SWISH-RUN 1" .TH SWISH-RUN 1 "2009-04-04" "2.4.7" "SWISH-E Documentation" .SH "NAME" SWISH\-RUN \- Running Swish\-e and Command Line Switches .SH "OVERVIEW" .IX Header "OVERVIEW" The Swish-e program is controlled by command line arguments (called \&\fIswitches\fR). Often, it is run manually from a shell (command prompt), or from a program such as a \s-1CGI\s0 script that passes the command line arguments to swish. .PP Note: A number of the command line switches may be specified in the Swish-e configuration file specified with the \f(CW\*(C`\-c\*(C'\fR command line argument. Please see SWISH-CONFIG for a complete description of available configuration file directives. .PP There are two basic operating modes of Swish\-e: indexing and searching. There are command line arguments that are unique to each mode, and others that apply to both (yet may have different meaning depending on the operating mode). These command line arguments are listed below, grouped by: .PP \&\s-1INDEXING\s0 \*(-- describes the command line arguments used while indexing. .PP \&\s-1SEARCHING\s0 \*(-- lists the command line arguments used while searching. .PP \&\s-1OTHER\s0 \s-1SWITCHES\s0 \*(-- lists switches that don't apply to searching or indexing. .PP Beginning with Swish-e version 2.1, you may embed its search engine into your applications. Please see SWISH-LIBRARY. .SH "INDEXING" .IX Header "INDEXING" Swish-e indexing is initiated by passing \fIcommand line arguments\fR to swish. The command line arguments used for \fIsearching\fR are described in \s-1SEARCHING\s0. Also, see SWISH-SEARCH for examples of searching with Swish\-e. .PP Swish-e usage: .PP .Vb 2 \& swish-e [-i dir file ... ] [-c file] [-f file] [-l] \e \& [-v (num)] [-S method(fs|http|prog)] [-N path] .Ve .PP The \f(CW\*(C`\-h\*(C'\fR switch (help) will list the available Swish-e command line arguments: .PP .Vb 1 \& swish-e -h .Ve .PP Typically, most if not all indexing settings are placed in a configuration file (specified with the \f(CW\*(C`\-c\*(C'\fR switch). Once the configuration file is setup indexing is initiated as: .PP .Vb 1 \& swish-e -c /path/to/config/file .Ve .PP See SWISH-CONFIG for information on the configuration file. .PP Security Note: If the swish binary is named \fIswish-search\fR then swish will not allow any operation that would cause swish to write to the index file. .PP When indexing it may be advisable to index to a temporary file, and then after indexing has successfully completed rename the file to the final location. This is especially important when replacing an index that is currently in use. .PP .Vb 3 \& swish-e -c swish.config -f index.tmp \& [check return code from swish or look for err: output] \& mv index.tmp index.swish-e .Ve .Sh "Indexing Command Line Arguments" .IX Subsection "Indexing Command Line Arguments" .IP "\-i *directories and/or files* (input file)" 4 .IX Item "-i *directories and/or files* (input file)" This specifies the directories and/or files to index. Directories will be indexed recursively. This is typically specified in the configuration file with the \fBIndexDir\fR directive instead of on the command line. Use of this switch overrides the configuration file settings. .IP "\-S [fs|http|prog] (document source/access mode)" 4 .IX Item "-S [fs|http|prog] (document source/access mode)" This specifies the method to use for accessing documents to index. Can be either \f(CW\*(C`fs\*(C'\fR for local indexing via the file system (the default), \&\f(CW\*(C`http\*(C'\fR for spidering, or \f(CW\*(C`prog\*(C'\fR for reading documents from an external program. .Sp Located in the \f(CW\*(C`conf\*(C'\fR directory are example configuration files that demonstrate indexing with the different document source methods. .Sp See the SWISH-FAQ for a discussion on the different indexing methods, and the difference between spidering with the http method vs. using the file system method. .RS 4 .IP "fs \- file system" 4 .IX Item "fs - file system" The \f(CW\*(C`fs\*(C'\fR method simply reads files from a local (or networked) drive. This is the default method if the \f(CW\*(C`\-S\*(C'\fR switch is not specified. See SWISH-CONFIG for configuration directives specific to the \f(CW\*(C`fs\*(C'\fR method. .IP "http \- spider a web server" 4 .IX Item "http - spider a web server" The \f(CW\*(C`http\*(C'\fR method is used to spider web servers. It uses an included helper program called \fIswishspider\fR. See SWISH-CONFIG for configuration directives specific to the \f(CW\*(C`http\*(C'\fR method. .Sp Security Note: Under Windows swish passes the URLs fetched from remote documents through the shell (swish uses the \fIsystem()\fR command for running \fIswishspider\fR under Windows), and this may be considered an additional security risk. .Sp The \f(CW\*(C`http\*(C'\fR method is deprecated (or at least not very well appreciated). Consider using the \f(CW\*(C`prog\*(C'\fR method described below for spidering. There's a spider program available in the \&\fIprog-bin\fR directory for use with the \f(CW\*(C`prog\*(C'\fR method. Here's a number of limitation with this method that are solved with the \f(CW\*(C`prog\*(C'\fR method: .RS 4 .IP "*" 4 swishspider only spiders standard links. Frames and other links are not followed. .IP "*" 4 By default, this method of spidering only indexes files that have a content type of \*(L"text/*\*(R" (e.g. text/plain, text/html, text/xml). You should use \f(CW\*(C`DefaultContents\*(C'\fR and \f(CW\*(C`IndexContents\*(C'\fR to map file extensions to parsers used by swish (e.g. \f(CW\*(C`IndexContents HTML* .html .htm\*(C'\fR), but this will fail where a document does not have a file extension. .IP "*" 4 Swish\-e's \f(CW\*(C`FileFilter\*(C'\fR directive can be used with the \f(CW\*(C`http\*(C'\fR access method, although it requires a separate process (in addition to the swsihspider process) for each document filtered. .IP "*" 4 The SWISH::Filter modules can be used with the swishspider program. SWISH::Filter provides a general purpose filtering system (see SWISH::Filter documentation). To use SWISH::Filter set \s-1PERL5LIB\s0 to point to the location of the \s-1SWISH\s0 module name space (typically /usr/local/lib/swish\-e under Unix). For example: .Sp .Vb 2 \& export PERL5LIB=/usr/local/lib/swish-e # bash, bourne shells \& setenv PERL5LIB /usr/local/lib/swish-e # csh, tcsh .Ve .Sp or under Windows .Sp .Vb 1 \& set PERL5LIB=c:\eprogram files\eswish-e2.4\elib\eswish-e .Ve .Sp SWISH::Filter is not enabled by default due to the overhead of loading the modules for every document fetched. .Sp The Swish-e distribution includes perl modules in the SWISH::Filters::* namespace to make converting non-text documents into a format that Swish-e can parse easy. As mentioned above, the helper script \&\fIswishspider\fR will use these modules if can be found via \s-1PERL5LIB\s0. These modules only provide an interface to programs that do the conversion. For example, you will need to download and install the \&\*(L"catdoc\*(R" program to convert MSWord documents into text for indexing. Please see \&\fIfilters/README\fR to see how to use this filter system. .RE .RS 4 .RE .IP "prog \- general purpose access method" 4 .IX Item "prog - general purpose access method" The \f(CW\*(C`prog\*(C'\fR method is new to Swish-e version 2.2. It's designed as a general purpose method to feed documents to swish from an external program. .Sp For example, the external program can read a database (e.g. MySQL), spider a web server, or convert documents from one format to another (e.g. pdf to html). Or, you can simply use it to read the files of the file system (like \f(CW\*(C`\-S fs\*(C'\fR), yet provide you with full control of what files are indexed. .Sp The external program name to run is passed to swish either by the IndexDir directive, or via the \f(CW\*(C`\-i\*(C'\fR option. .Sp The program specified should be an absolute path as swish-e will attempt to \fIstat()\fR the program to make sure it exists. Swish does this to help in error reporting. .Sp If the program specified with \-i or IndexDir is not an absolute path (i.e. does not include \*(L"/\*(R" ) then swish-e will append the \*(L"libexecdir\*(R" directory defined during configuration. Typically, libexecdir is set to \&\*(L"$prefix/lib/swish\-e\*(R" (/usr/local/lib/swish\-e), but is platform and installation dependent. Running swish-e \-h will report the directory. .Sp For example, the \-S prog program \*(L"spider.pl\*(R" is a Perl helper program for use with \-S prog and is installed in libexecdir. .Sp .Vb 2 \& IndexDir spider.pl \& SwishProgParameters default http://localhost/index.html .Ve .Sp and swish-e will find spider.pl in libexecdir. .Sp Additional parameters may be passed to the external program via the SwishProgParameters directive. In the example above swish-e will pass two parameters to spider.pl, \*(L"default\*(R" and \&\*(L"http://localhost/index.html\*(R". .Sp A special name \*(L"stdin\*(R" may be used with \f(CW\*(C`\-i\*(C'\fR or IndexDir which tells swish to read from standard input instead of from an external program. See example below. .Sp The external program prints to standard output (which swish captures) a set of headers followed by the content of the file to index. The output looks similar to an email message or a \s-1HTTP\s0 document returned by a web server in that it includes name/value pairs of headers, a blank line, and the content. .Sp The content length is determined by a content-length header supplied to swish by the program; there is no \*(L"end of record\*(R" character or flag sent between documents. Therefore, it is critical that the content-length header is correct. This is a common source of errors. .Sp One advantage of this method (over using filters, for example) is that the external program is run only once for the entire indexing job, instead of once for every document. This avoids forking and creating a new process for every document, and makes a huge difference when your external program is something like perl that has a large startup cost. .Sp Here's a simple example written in Perl: .Sp .Vb 2 \& #!/usr/local/bin/perl -w \& use strict; .Ve .Sp .Vb 11 \& # Build a document \& my $doc = < \& \& Document Title \& \& \& This is the text. \& \& \& EOF .Ve .Sp .Vb 4 \& # Prepare the headers for swish \& my $path = 'Example.file'; \& my $size = length $doc; \& my $mtime = time; .Ve .Sp .Vb 6 \& # Output the document (to swish) \& print <content_type =~ m!text/html!' .Ve .Sp This header is not required. .IP "Update\-Mode:" 4 .IX Item "Update-Mode:" When updating an incremental index this header can be used to select the mode for updating the index. There are three possible values: .Sp .Vb 3 \& Update \& Remove \& Index .Ve .Sp \&\*(L"Update\*(R" will update the index with the given file if the date of the given file is newer than the date of the file already in the index. Setting to \*(L"Update\*(R" is the same as using \-u on the command line. .Sp \&\*(L"Remove\*(R" mode will remove the file specified by the Path-Name header. Setting \*(L"Remove\*(R" is the same as using \-r on the command line. .Sp \&\*(L"Index\*(R" will add the file to the index. \s-1NOTE:\s0 swish-e will not check to see if the file already exists. .Sp If this header is not specified, the default is the mode specified on the command line (\-u, \-r, or none). .Sp This option is still experimental and is subject to change in the future. Ask on the Swish-e list before using. .RE .RS 4 .Sp The above example program only returns one document and exits, which is not very useful. Normally, your program would read data from some source, such as files or a database, format as \&\s-1XML\s0, \s-1HTML\s0, or text, and pass them to swish, one after another. The \f(CW\*(C`Content\-Length:\*(C'\fR header tells swish where each document ends \*(-- there is not any special \*(L"end of record\*(R" character or marker. .Sp To index with the above example you need to make sure that the program is executable (and that the path to perl is correct), and then call swish telling to run in \f(CW\*(C`prog\*(C'\fR mode, and the name of the program to use for input. .Sp .Vb 2 \& % chmod 755 example.pl \& % ./swish-e -S prog -i ./example.pl .Ve .Sp Programs can and should be tested prior to running swish. For example: .Sp .Vb 1 \& % ./example.pl > test.out .Ve .Sp A few more useful example programs are provided in the swish-e distribution located in the \fIprog-bin\fR directory. Some include documentation: .Sp .Vb 2 \& % cd prog-bin \& % perldoc spider.pl .Ve .Sp Others are small examples that include comments: .Sp .Vb 2 \& % cd prog-bin \& % less DirTree.pl .Ve .Sp The \fIspider.pl\fR program can be used as a replacement for the \fI\-S http\fR method. It is far more feature-rich and offers much more control over indexing. .Sp If you use the special program name \*(L"stdin\*(R" with \f(CW\*(C`\-i\*(C'\fR or IndexDir then swish-e will read from standard input instead of from a program. For example: .Sp .Vb 1 \& % ./example.pl --count=1000 /path/to/data | ./swish-e -S prog -i stdin .Ve .Sp This is basically the same as using a swish-e configuration file of: .Sp .Vb 2 \& SwishProgParameters --count=1000 /path/to/data \& IndexDir ./example.pl .Ve .Sp in a config file and running .Sp .Vb 1 \& % ./swish-e -S prog -c swish.conf .Ve .Sp This gives an easy way to run swish without a configuration file with a \f(CW\*(C`\-S prog\*(C'\fR program that requires parameters. It also means you can capture data to a file and then index more once with the same data: .Sp .Vb 3 \& % ./example.pl /path/to/data --count=1000 > docs.txt \& % cat docs.txt | ./swish-e -S prog -i stdin -c normal_index \& % cat docs.txt | ./swish-e -S prog -i stdin -c fuzzy_index .Ve .Sp Using \*(L"stdin\*(R" might also be useful for programs that call swish (instead of swish calling the program). .Sp (The reason \*(L"stdin\*(R" is used instead of the more common \*(L"\-\*(R" dash is due to the rotten way swish parses the command line. This should be fixed in the future.) .Sp The \f(CW\*(C`prog\*(C'\fR method bypasses some of the configuration parameters available to the file system method \*(-- settings such as \&\f(CW\*(C`IndexOnly\*(C'\fR, \f(CW\*(C`FileRules\*(C'\fR, \f(CW\*(C`FileMatch\*(C'\fR and \f(CW\*(C`FollowSymLinks\*(C'\fR are ignored when using the \f(CW\*(C`prog\*(C'\fR method. It's expected that these operations are better accomplished in the external program before passing the document onto swish. In other words, when using the \f(CW\*(C`prog\*(C'\fR method, only send the documents to swish that you want indexed. .Sp You may use swish's filter feature with the \f(CW\*(C`prog\*(C'\fR method, but performance will be better if you run filtering programs from within your external program. See also \fIfilters/README\fR for an example how to easily add document converstion and filtering into your Perl-based programs. .Sp \&\fBNotes when using \-S prog on \s-1MS\s0 Windows\fR .Sp Windows does not use the shebang (#!) line of a program to determine the program to run. So, when running, for example, a perl program you may need to specify the perl.exe binary as the program, and use the \&\f(CW\*(C`SwishProgParameters\*(C'\fR to name the file. .Sp .Vb 2 \& IndexDir e:/perl/bin/perl.exe \& SwishProgParameters read_database.pl .Ve .Sp Swish will replace the forward slashes with backslashes before running the command specified with \&\f(CW\*(C`IndexDir\*(C'\fR. Swish uses the \fIpopen\fR\|(3) command which passes the command through the shell. .RE .RE .RS 4 .RE .IP "\-f *indexfile* (index file)" 4 .IX Item "-f *indexfile* (index file)" If you are indexing, this specifies the file to save the generated index in, and you can only specify one file. See also \fBIndexFile\fR in the configuration file. .Sp If you are searching, this specifies the index files (one or more) to search from. The default index file is index.swish\-e in the current directory. .IP "\-c *file ...* (configuration files)" 4 .IX Item "-c *file ...* (configuration files)" Specify the configuration file(s) to use for indexing. This file contains many directives that control how Swish-e proceeds. See SWISH-CONFIG for a complete listing of configuration file directives. .Sp Example: .Sp .Vb 1 \& swish-e -c docs.conf .Ve .Sp If you specify a directory to index, an index file, or the verbose option on the command\-line, these values will override any specified in the configuration file. .Sp You can specify multiple configuration files. For example, you may have one configuration file that has common site-wide settings, and another for a specific index. .Sp Examples: .Sp .Vb 3 \& 1) swish-e -c swish-e.conf \& 2) swish-e -i /usr/local/www -f index.swish-e -v -c swish-e.conf \& 3) swish-e -c swish-e.conf stopwords.conf .Ve .RS 4 .IP "1" 3 .IX Item "1" The settings in the configuration file will be used to index a site. .IP "2" 3 .IX Item "2" These command-line options will override anything in the configuration file. .IP "3" 3 .IX Item "3" The variables in swish\-e.conf will be read, then the variable in stopwords.conf will be read. Note that if the same variables occur in both files, older values may be written over. .RE .RS 4 .RE .IP "\-e (economy mode)" 4 .IX Item "-e (economy mode)" For large sites indexing may require more \s-1RAM\s0 than is available. The \f(CW\*(C`\-e\*(C'\fR switch tells swish to use disk space to store data structures while indexing, saving memory. This option is recommended if swish uses so much \s-1RAM\s0 that the computer begins to swap excessively, and you cannot increase available memory. The trade-off is slightly longer indexing times, and a busy disk drive. .IP "\-l (symbolic links)" 4 .IX Item "-l (symbolic links)" Specifying this option tells swish to follow symbolic links when indexing. The configuration file value \fBFollowSymLinks\fR will override the command-line value. .Sp The default is not to follow symlinks. A small improvement in indexing time my result from enabling FollowSymLinks since swish does not need to stat every directory and file processed to determine if it is a symbolic link. .IP "\-N path (index only newer files)" 4 .IX Item "-N path (index only newer files)" The \f(CW\*(C`\-N\*(C'\fR option takes a path to a file, and only files \fInewer\fR than the specified file will be indexed. This is helpful for creating incremental indexes \*(-- that is, indexes that contain just files added since the last full index was created of all files. .Sp Example (bad example) .Sp .Vb 1 \& swish-e -c config.file -N index.swish-e -f index.new .Ve .Sp This will index as normal, but only files with a modified date newer than \fIindex.swish\-e\fR will be indexed. .Sp This is a bad example because it uses \fIindex.swish\-e\fR which one might assume was the date of last indexing. The problem is that files might have been added between the time indexing read the directory and when the \fIindex.swish\-e\fR file was created \*(-- which can be quite a bit of time for very large indexing jobs. .Sp The only solution is to prevent any new file additions while full indexing is running. If this is impossible then it will be slightly better to do this: .Sp Full indexing: .Sp .Vb 3 \& touch indexing_time.file \& swish-e -c config.file -f index.tmp \& mv index.tmp index.full .Ve .Sp Incremental indexing: .Sp .Vb 2 \& swish-e -c config.file -N indexing_time.file -f index.tmp \& mv index.tmp index.incremental .Ve .Sp Then search with .Sp .Vb 1 \& swish-e -w foo -f index.full index.incremental .Ve .Sp or merge the indexes .Sp .Vb 3 \& swish-e -M index.full index.incremental index.tmp \& mv index.tmp index.swish-e \& swish-e -w foo .Ve .IP "\-r" 4 .IX Item "-r" \&\fB**incremental index format only**\fR The \f(CW\*(C`\-r\*(C'\fR option puts swish-e into \*(L"removal\*(R" mode. Any input files (given with \f(CW\*(C`\-i\*(C'\fR or the \f(CW\*(C`IndexDir\*(C'\fR parameter) are removed from an existing index. .Sp Example: .Sp .Vb 1 \& swish-e -r -i file.html .Ve .Sp would remove \fIfile.html\fR from the existing index. .IP "\-u" 4 .IX Item "-u" \&\fB**incremental index format only**\fR The \f(CW\*(C`\-u\*(C'\fR option puts swish-e into \*(L"update\*(R" mode. The timestamp of each input file is compared against the corresponding file in the existing index. If swish-e encounters an input file that either does not exist yet in the index or exists with a timestamp older than the input file, the input file is updated in the index. Any words in the input file that have been added or removed are reflected as such in the index. .Sp Example: .Sp .Vb 1 \& swish-e -i file.html -u .Ve .Sp would update the index.swish\-e index with the contents of file.html. If file.html was new, it would be added. If file.html already existed in the index, its contents would be updated in the index. .IP "\-v [0|1|2|3] (verbosity level)" 4 .IX Item "-v [0|1|2|3] (verbosity level)" The \f(CW\*(C`\-v\*(C'\fR option can take a numerical value from 0 to 3. Specify 0 for completely silent operation and 3 for detailed reports. .Sp If no value is given then 1 is assumed. See also \fBIndexReport\fR in the configuration file. .Sp Warnings and errors are reported regardless of the verbosity level. In addition, all error and warnings are written to standard out. This is for historical reasons (many scripts exist that parse standard out for error messages). .IP "\-W (0|1|2|3) (parser warning level)" 4 .IX Item "-W (0|1|2|3) (parser warning level)" If using the libxml2 parser, the default parser warning level is set at \f(CW2\fR. Use the \f(CW\*(C`\-W\*(C'\fR option to override that default. Most often, you might want to turn it off altogether: .Sp .Vb 1 \& swish-e -W0 -i path/to/files .Ve .Sp would fail silently if the parser encountered any errors. .SH "SEARCHING" .IX Header "SEARCHING" The following command line arguments are available when searching with Swish\-e. These switches are used to select the index to search, what fields to search, and how and what to print as results. .PP This section just lists the available command line arguments and their usage. Please see SWISH-SEARCH for detailed searching instructions. .PP \&\fBWarning\fR: If using Swish-e via a \s-1CGI\s0 interface, please see \s-1CGI\s0 Danger! .PP Security Note: If the swish binary is named \fIswish-search\fR then swish will not allow any operation that would cause swish to write to the index file. .Sh "Searching Command Line Arguments" .IX Subsection "Searching Command Line Arguments" .IP "\-w *word1 word2 ...* (query words)" 4 .IX Item "-w *word1 word2 ...* (query words)" This performs a case-insensitive search using a number of keywords. If no index file to search is specified (via the \f(CW\*(C`\-f\*(C'\fR switch), swish-e will try to search a file called index.swish\-e in the current directory. .Sp .Vb 1 \& swish-e -w word .Ve .Sp Phrase searching is accomplished by placing the quote delimiter (a double-quote by default) around the search phrase. .Sp .Vb 1 \& swish-e -w 'word or "this phrase"' .Ve .Sp Search would should be protected from the shell by quotes. Typically, this is single quotes when running under Unix. .Sp Under Windows \fIcommand.com\fR you may not need to use quotes, but you will need to backslash the quotes used to delimit phrases: .Sp .Vb 1 \& swish-e -w \e"a phrase\e" .Ve .Sp The phrase delimiter can be set with the \f(CW\*(C`\-P\*(C'\fR switch. .Sp The search may be limited to a \fIMetaName\fR. For example: .Sp .Vb 1 \& swish-e -w meta1=(foo or baz) .Ve .Sp will only search within the \fBmeta1\fR tag. .Sp Please see SWISH-SEARCH for a description of MetaNames .IP "\-f *file1 file2 ...* (index files)" 4 .IX Item "-f *file1 file2 ...* (index files)" Specifies the index file(s) used while searching. More than one file may be listed, and each file will be searched. If no \f(CW\*(C`\-f\*(C'\fR switch is specified then the file \fIindex.swish\-e\fR in the current directory will be used as the index file. .IP "\-m *number* (max results)" 4 .IX Item "-m *number* (max results)" While searching, this specifies the maximum number of results to return. The default is to return all results. .Sp This switch is often used in conjunction with the \f(CW\*(C`\-b\*(C'\fR switch to return results one page at a time (strongly recommended for large indexes). .IP "\-b *number* (beginning result)" 4 .IX Item "-b *number* (beginning result)" Sets the \fIbegining\fR search result to return (records are numbered from 1). This switch can be used with the \f(CW\*(C`\-m\*(C'\fR switch to return results in groups or pages. .Sp Example: .Sp .Vb 2 \& swish-e -w 'word' -b 1 -m 20 # first 'page' \& swish-e -w 'word' -b 21 -m 20 # second 'page' .Ve .IP "\-t HBthec (context searching)" 4 .IX Item "-t HBthec (context searching)" The \f(CW\*(C`\-t\*(C'\fR option allows you to search for words that exist only in specific \s-1HTML\s0 tags. Each character in the string you specify in the argument to this option represents a different tag in which to search for the word. H means all \s-1HEAD\s0 tags, B stands for \s-1BODY\s0 tags, t is all \s-1TITLE\s0 tags, h is H1 to H6 (header) tags, e is emphasized tags (this may be B, I, \&\s-1EM\s0, or \s-1STRONG\s0), and c is \s-1HTML\s0 comment tags .Sp search only in header () tags .Sp .Vb 1 \& swish-e -w word -t h .Ve .IP "\-d *string* (delimiter)" 4 .IX Item "-d *string* (delimiter)" Set the delimiter used when printing results. By default, Swish-e separates the output fields by a space, and places double-quotes around the document title. This output may be hard to parse, so it is recommended to use \f(CW\*(C`\-d\*(C'\fR to specify a character or string used as a separator between fields. .Sp The string \f(CW\*(C`dq\*(C'\fR means \*(L"double\-quotes\*(R". .Sp .Vb 5 \& swish-e -w word -d , # single char \& swish-e -w word -d :: # string \& swish-e -w word -d '"' # double quotes under Unix \& swish-e -w word -d \e" # double quotes under Windows \& swish-e -w word -d dq # double quotes .Ve .Sp The following control characters may also be specified: \f(CW\*(C`\et \er \en \ef\*(C'\fR. .Sp Warning: This string is passed directly to \fIsprintf()\fR and therefore exposes a securty hole. Do not allow user data to set \-d format strings directly. .IP "\-P *character*" 4 .IX Item "-P *character*" Sets the delimiter used for phrase searches. The default is double quotes \f(CW\*(C`"\*(C'\fR. .Sp Some examples under bash: (be careful about you shell metacharacters) .Sp .Vb 2 \& swish-e -P ^ -w 'title=^words in a phrase^' \& swish-e -P \e' -w "title='words in a pharse"' .Ve .IP "\-p *property1 property2 ...* (display properties)" 4 .IX Item "-p *property1 property2 ...* (display properties)" This causes swish to print the listed property in the search results. The properties are returned in the order they are listed in the \f(CW\*(C`\-p\*(C'\fR argument. .Sp Properties are defined by the \fBProperNames\fR directive in the configuration file (see SWISH-CONFIG) and properties must also be defined in \fBMetaNames\fR. Swish stores the text of the meta name as a \fIproperty\fR, and then will return this text while searching if this option is used. .Sp Properties are very useful for returning data included in a source documnet without having to re-read the source document while searching. For example, this could be used to return a short document description. See also see \fBDocument Summeries\fR and PropertyNames in SWISH-CONFIG. .Sp To return the subject and category properties while indexing. .Sp .Vb 1 \& swish-e -w word -p subject category .Ve .Sp Properties are returned in double quotes. If a property contains a double quote it is \s-1HTML\s0 escaped ("). See the \f(CW\*(C`\-x\*(C'\fR switch for a more advanced method of returning a list of properties. .Sp \&\s-1NOTE:\s0 it is necessary to have indexed with the proper PropertyNames directive in the user config file in order to use this option. .IP "\-s *property [asc|desc] ...* (sort)" 4 .IX Item "-s *property [asc|desc] ...* (sort)" Normally, search results are printed out in order of relevancy, with the most relevant listed first. The \f(CW\*(C`\-s\*(C'\fR sort switch allows you to sort results in order of a specified \fIproperty\fR, where a \fIproperty\fR was defined using the \fBMetaNames\fR and \fBPropertyNames\fR directives during indexing (see SWISH-CONFIG). .Sp The string passed can include the strings \f(CW\*(C`asc\*(C'\fR and \f(CW\*(C`desc\*(C'\fR to specify the sort order, and more than one property may be specified to sort on more than one key. .Sp Examples: .Sp sort by title property ascending order .Sp .Vb 1 \& -s title .Ve .Sp sort descending by title, ascending by name .Sp .Vb 1 \& -s title desc name asc .Ve .Sp Note: Swish limits sort keys to 100 characters. This limit can be changed by changing \s-1MAX_SORT_STRING_LEN\s0 in src/config.h and rebuilding swish\-e. .IP "\-L limit to a range of property values (Limit)" 4 .IX Item "-L limit to a range of property values (Limit)" \&\fBThis is an experimental feature!\fR .Sp The \f(CW\*(C`\-L\*(C'\fR switch can be used to limit search results to a range of property values .Sp Example: .Sp .Vb 1 \& swish-e -w foo -L swishtitle a m .Ve .Sp finds all documents that contain the word \f(CW\*(C`foo\*(C'\fR, and where the document's title is in the range of \f(CW\*(C`a\*(C'\fR to \f(CW\*(C`m\*(C'\fR, inclusive. By default, the case of the property is ignored, but this can be changed by using PropertyNamesCompareCase configuation directive. .Sp Limiting may be done with user-defined properties, as well. .Sp For example, if you indexed documents that contain a created timestamp in a meta tag: .Sp .Vb 1 \& .Ve .Sp Then you tell Swish that you have a property called \f(CW\*(C`created_on\*(C'\fR, and that it's a timestamp. .Sp .Vb 1 \& PropertyNamesDate created_on .Ve .Sp After indexing you will be able to limit documents to a range of timestamps: .Sp .Vb 1 \& -w foo -L created_on 946684800 949363199 .Ve .Sp will find documents containing the word foo and that have a created_on date from the start of Jan 1, 2000 to the end of Jan 31, 2000. .Sp Note: swish currently does not parse dates; Unix timestamps must be used. .Sp Two special formats can be used: .Sp .Vb 2 \& -L swishtitle <= m \& -L swishtitle >= m .Ve .Sp Finds titles less than or equal, or grater than or equal to the letter \f(CW\*(C`m\*(C'\fR. .Sp This feature will not work with \f(CW\*(C`swishrank\*(C'\fR or \f(CW\*(C`swishdbfile\*(C'\fR properties. .Sp This feature takes advantages of the pre-sorted tables built by swish during indexing to make this feature fast while searching. You should see in the indexing output a line such as: .Sp .Vb 1 \& 6 properties sorted. .Ve .Sp That indicates that six pre-sorted tables were built during indexing. By default, all properties are presorted while indexing. What properties are pre-sorted can be controlled by the configuration parameter \f(CW\*(C`PreSortedIndex\*(C'\fR. .Sp Using the \f(CW\*(C`\-L\*(C'\fR switch on a property that was not pre-sorted will still work, but may be \fImuch\fR slower during searching. .Sp Note that the PropertyNamesSortKeyLength setting is used for sorting properties. Using too small a PropertyNamesSortKeyLength could result in \-L selecting the wrong properties due to incomplete sorting. .Sp This is an experimental feature, and its use and interface are subject to change. .IP "\-x formatstring (extended output format)" 4 .IX Item "-x formatstring (extended output format)" The \f(CW\*(C`\-x\*(C'\fR switch defines the output format string. The format string can contain plain text and property names (including swish-defined internal property names) and is used to generate the output for every result. In addition, the output format of the property name can be controlled with C\-like printf format strings. This feature overrides the cmdline switches \f(CW\*(C`\-d\*(C'\fR and \&\f(CW\*(C`\-p\*(C'\fR, and a warning will be generated if \f(CW\*(C`\-d\*(C'\fR or \f(CW\*(C`\-p\*(C'\fR are used with \f(CW\*(C`\-x\*(C'\fR. .Sp Warning: The format string (fmt) is passed directly to \fIsprintf()\fR and therefore exposes a securty hole. Do not allow user data to set \-x format strings directly. .Sp For example, to return just the title, one per line, in the search results: .Sp .Vb 1 \& swish-e -w ... -x '\en' ... .Ve .Sp Note: the \f(CW\*(C`\en\*(C'\fR may need to be protected from your shell. .Sp See also ResultExtFormatName for a way to define \fInamed\fR format strings in the swish configuration file. .Sp \&\fBFormat of \*(L"formatstring\*(R":\fR .Sp .Vb 1 \& "texttexttext..." .Ve .Sp Where \fBpropertyname\fR is: .RS 4 .IP "*" 4 the name of a user property as specified with the config file directive \*(L"PropertyNames\*(R" .IP "*" 4 the name of a swish Auto property (see below). These properties are defined automatically by swish \*(-- you do not need to specify them with PropertyNames directive. (This may change in the future.) .RE .RS 4 .Sp propertynames must be placed within "<\*(L" and \*(R">". .Sp \&\fBUser properties:\fR .Sp Swish-e allows you to specify certain \s-1META\s0 tags within your documents that can be used as \fBdocument properties\fR. The contents of any \s-1META\s0 tag that has been identified as a document property can be returned as part of the search results. Doucment properties must be defined while indexing using the \fBPropertyNames\fR configuration directive (see SWISH-CONFIG). .Sp Examples of user-defined PropertyNames: .Sp .Vb 5 \& \& \& \& \& .Ve .Sp \&\fBAuto properties:\fR .Sp Swish defines a number of \*(L"Auto\*(R" properties for each document indexed. These are available for output when using the \f(CW\*(C`\-x\*(C'\fR format. .Sp .Vb 10 \& Name Type Contents \& -------------- ------- ---------------------------------------------- \& swishreccount Integer Result record counter \& swishtitle String Document title \& swishrank Integer Result rank for this hit \& swishdocpath String URL or filepath to document \& swishdocsize Integer Document size in bytes \& swishlastmodified Date Last modified date of document \& swishdescription String Description of document (see:StoreDescription) \& swishdbfile String Path of swish database indexfile .Ve .Sp The Auto properties can also be specified using shortcuts: .Sp .Vb 10 \& Shortcut Property Name \& -------- -------------- \& %c swishreccount \& %d swishdescription \& %D swishlastmodified \& %I swishdbfile \& %p swishdocpath \& %r swishrank \& %l swishdocsize \& %t swishtitle .Ve .Sp For example, these are equivalent: .Sp .Vb 2 \& -x '::\en' \& -x '%r:%p:%t\en' .Ve .Sp Use a double percent sign \*(L"%%\*(R" to enter a literal percent sign in the output. .Sp \&\fBFormatstrings of properties:\fR .Sp Properties listed in an \f(CW\*(C`\-x\*(C'\fR format string can include format control strings. These \*(L"propertyformats\*(R" are used to control how the contents of the associated property are printed. Property formats are used like C\-language printf formats. The property format is specified by including the attribute \*(L"fmt\*(R" within the property tag. .Sp Format strings cannot be used with the \*(L"%\*(R" shortcuts described above. .Sp General syntax: .Sp .Vb 1 \& -x '' .Ve .Sp where \f(CW\*(C`subfmt\*(C'\fR controls the output format of \f(CW\*(C`propertyname\*(C'\fR. .Sp Examples of property format strings: .Sp .Vb 3 \& date type: \& string type: \& integer type: .Ve .Sp Please see the manual pages for \fIstrftime\fR\|(3) and \fIsprintf\fR\|(3) for an explanation of format strings. Note: some versions of strftime do not offer the \f(CW%s\fR format string (number of seconds since the Epoch), so swish provides a special format string \*(L"%ld\*(R" to display the number of seconds since the Epoch. .Sp The first character of a property format string defines the delimiter for the format string. For example, .Sp .Vb 3 \& -x " ...\en" \& -x " ...\en" \& -x " ...\en" .Ve .Sp \&\fBStandard predefined formats:\fR .Sp If you ommit the sub\-format, the following formats are used: .Sp .Vb 4 \& String type: "%s" (like printf char *) \& Integer type: "%d" (like printf int) \& Float type: "%f" (like printf double) \& Date type: "%Y-%m-%d %H:%M:%S" (like strftime) .Ve .Sp \&\fBText in \*(L"formatstring\*(R" or \*(L"propfmtstr\*(R":\fR .Sp Text will be output as-is in format strings (and property format strings). Special characters can be escaped with a backslash. To get a new line for each result hit, you have to include the Newline-Character \*(L"\en\*(R" at the end of \*(L"fmtstr\*(R". .Sp .Vb 5 \& -x "||\en" \& -x "Count=, Rank=\en" \& -x "Title=\e\e" \& -x 'Date: \en' \& -x 'Date in seconds: \en' .Ve .Sp \&\fBControl/Escape charcters:\fR .Sp you can use C\-like control escapes in the format string: .Sp .Vb 3 \& known controls: \ea, \eb, \ef, \en, \er, \et, \ev, \& digit escapes: \exhexdigits \e0octaldigits \& character escapes: \eanychar .Ve .Sp Example, .Sp .Vb 1 \& swish -x "%c\et%r\et%p\et\e"\e"\en" .Ve .Sp \&\fBExamples of \-x format strings:\fR .Sp .Vb 5 \& -x "%c|%r|%p|%t|%D|%d\en" \& -x "%c|%r|%p|%t||%d\en" \& -x "\et\et\et\en \& -x "xml_out: \e\e>\e\en" \& -x "xml_out: \en" .Ve .RE .IP "\-H [0|1|2|3|] (header output verbosity)" 4 .IX Item "-H [0|1|2|3|] (header output verbosity)" The \f(CW\*(C`\-H n\*(C'\fR switch generates extened \fIheader\fR output. This is most useful when searching more than one index file at a time by specifying more than one index file with the \f(CW\*(C`\-f\*(C'\fR switch. \&\f(CW\*(C`\-H 2\*(C'\fR will generate a set of headers specific to each index file. This gives access to the settings used to generate each index file. .Sp Even when searching a single index file, \f(CW\*(C`\-H n\*(C'\fR will provided additional information about the index file, how it was indexed, and how swish is interperting the query. .Sp .Vb 5 \& -H 0 : print no header information, output only search result entries. \& -H 1 : print standard result header (default). \& -H 2 : print additional header information for each searched index file. \& -H 3 : enhanced header output (e.g. print stopwords). \& -H 9 : print diagnostic information in the header of the results (changed from: C<-v 4>) .Ve .IP "\-R [0|1] (Ranking Scheme)" 4 .IX Item "-R [0|1] (Ranking Scheme)" \&\fBThis is an experimental feature!\fR .Sp The default ranking scheme in SWISH-E evaluates each word in a query in terms of its frequency and position in each document. The default scheme is 0. .Sp New in version 2.4.3 you may optionally select an experimental ranking scheme that, in addition to document frequency and position, uses Inverse Document Frequency (\s-1IDF\s0), or the relative frequency of each word across all the indexes being searched, and Relative Density, or the normalization of the frequency of a word in relationship to the number of words in the document. .Sp \&\fB\s-1NOTE:\s0\fR IgnoreTotalWordCountWhenRanking must be set to \fBno\fR or \fB0\fR in your index(es) for \-R 1 to work. .Sp Specify \-R 1 to turn on \s-1IDF\s0 ranking. See the \s-1API\s0 documentation for how to set the ranking scheme in your Perl or C program. .SH "OTHER SWITCHES" .IX Header "OTHER SWITCHES" .IP "\-V (version)" 4 .IX Item "-V (version)" Print the current version. .IP "\-k *letter* (print out keywords)" 4 .IX Item "-k *letter* (print out keywords)" The \f(CW\*(C`\-k\*(C'\fR switch is used for testing and will cause swish to print out all keywords in the index beginning with that letter. You may enter \f(CW\*(C`\-k '*'\*(C'\fR to generate a list of all words indexed by swish. .IP "\-D *index file* (debug index)" 4 .IX Item "-D *index file* (debug index)" The \-D option is no longer supported in version 2.2. .IP "\-T *options* (trace/debug swish)" 4 .IX Item "-T *options* (trace/debug swish)" The \-T option is used to print out information that may be helpful when debugging swish\-e's operation. This option replaced the \f(CW\*(C`\-D\*(C'\fR option of previous versions. .Sp Running \f(CW\*(C`\-T help\*(C'\fR will print out a list of available *options* .SH "Merging Index Files" .IX Header "Merging Index Files" In previous versions of Swish-e indexing would require a very large amount of memory and the indexing process could be very slow. Merging provided a way to index in chunks and then combine the indexes together into a single index. .PP Indexing is much faster now and uses much less memory, and with the \f(CW\*(C`\-e\*(C'\fR switch very little memory is needed to index a large site. .PP Still, at times it can be useful to merge different index files into one file for searching. This could be because you want to keep separate site indexes and a common one for a global search, or you have separate collections of documents that you wish to search all at one time, but manage separately. .IP "\-M *index1 index2 ... indexN out_index" 4 .IX Item "-M *index1 index2 ... indexN out_index" Merges the indexes specified on the command line \*(-- the last file name entered is the output file. The output index must not exist (otherwise merge will not proceed). .Sp Only indexes that were indexed with common settings may be merged. (e.g. don't mix stemming and non-stemming indexes, or indexes with different WordCharacter settings, etc.). .Sp Use the \f(CW\*(C`\-e\*(C'\fR switch while merging to reduce memory usage. .Sp Merge generates progress messages regardless of the setting of \f(CW\*(C`\-v\*(C'\fR. .IP "\-c *configuration file*" 4 .IX Item "-c *configuration file*" Specify a configuration file while indexing to add administrative information to the output index file. .SH "Document Info" .IX Header "Document Info" $Id: \s-1SWISH\-RUN\s0.pod 1741 2005\-05\-17 02:22:40Z karman $ .PP \&.