1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>SWISH-Enhanced: SWISH-RUN - Running Swish-e and Command Line Switches </title>
<link href="./style.css" rel=stylesheet type="text/css" title="refstyle">
</head>
<body>
<h1 class="banner">
<a href="http://swish-e.org"><img border=0 src="images/swish.gif" alt="Swish-E Logo"></a><br>
<img src="images/swishbanner1.gif"><br>
<img src="images/dotrule1.gif"><br>
SWISH-RUN - Running Swish-e and Command Line Switches
</h1>
<hr>
<p>
<div class="navbar">
<a href="./SWISH-CONFIG.html">Prev</a> |
<a href="./index.html">Contents</a> |
<a href="./SWISH-SEARCH.html">Next</a>
</div>
<p>
<div class="toc">
<A NAME="toc"></A>
<P><B>Table of Contents:</B></P>
<UL>
<LI><A HREF="#OVERVIEW">OVERVIEW</A>
<LI><A HREF="#INDEXING">INDEXING</A>
<UL>
<LI><A HREF="#Indexing_Command_Line_Arguments">Indexing Command Line Arguments</A>
</UL>
<LI><A HREF="#SEARCHING">SEARCHING</A>
<UL>
<LI><A HREF="#Searching_Command_Line_Arguments">Searching Command Line Arguments</A>
</UL>
<LI><A HREF="#OTHER_SWITCHES">OTHER SWITCHES</A>
<LI><A HREF="#Merging_Index_Files">Merging Index Files</A>
<LI><A HREF="#Document_Info">Document Info</A>
</UL>
</div>
[ <B><FONT SIZE=-1><A HREF="#toc">TOC</A></FONT></B> ]
<HR>
<P>
<H1><A NAME="OVERVIEW">OVERVIEW</A></H1>
<P>
The Swish-e program is controlled by command line arguments (called
<EM>switches</EM>). Often, it is run manually from a shell (command prompt), or from a
program such as a CGI script that passes the command line arguments to
swish.
<P>
Note: A number of the command line switches may be specified in the Swish-e
configuration file specified with the <CODE>-c</CODE> command line argument. Please see <A HREF="././SWISH-CONFIG.html">SWISH-CONFIG</A> for a complete description of available configuration file directives.
<P>
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:
<P>
<A HREF="#INDEXING">INDEXING</A> -- describes the command line arguments used while indexing.
<P>
<A HREF="#SEARCHING">SEARCHING</A> -- lists the command line arguments used while searching.
<P>
<A HREF="#OTHER_SWITCHES">OTHER SWITCHES</A> -- lists switches that don't apply to searching or indexing.
<P>
Beginning with Swish-e version 2.1, you may embed its search engine into
your applications. Please see <A HREF="././SWISH-LIBRARY.html">SWISH-LIBRARY</A>.
<P>
[ <B><FONT SIZE=-1><A HREF="#toc">TOC</A></FONT></B> ]
<HR>
<H1><A NAME="INDEXING">INDEXING</A></H1>
<P>
Swish-e indexing is initiated by passing <EM>command line arguments</EM> to swish. The command line arguments used for <EM>searching</EM> are described in <A HREF="#SEARCHING">SEARCHING</A>. Also, see <A HREF="././SWISH-SEARCH.html">SWISH-SEARCH</A>
for examples of searching with Swish-e.
<P>
Swish-e usage:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> swish-e [-i dir file ... ] [-c file] [-f file] [-l] \
[-v (num)] [-S method(fs|http|prog)] [-N path]</pre>
</td>
</tr>
</table>
<P>
The <CODE>-h</CODE> switch (help) will list the available Swish-e command line arguments:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> swish-e -h</pre>
</td>
</tr>
</table>
<P>
Typically, most if not all indexing settings are placed in a configuration
file (specified with the <CODE>-c</CODE> switch). Once the configuration file is setup indexing is initiated as:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> swish-e -c /path/to/config/file</pre>
</td>
</tr>
</table>
<P>
See <A HREF="././SWISH-CONFIG.html">SWISH-CONFIG</A> for information on the configuration file.
<P>
Security Note: If the swish binary is named <EM>swish-search</EM> then swish will not allow any operation that would cause swish to write to
the index file.
<P>
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.
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> swish-e -c swish.config -f index.tmp
[check return code from swish or look for err: output]
mv index.tmp index.swish-e</pre>
</td>
</tr>
</table>
<P>
[ <B><FONT SIZE=-1><A HREF="#toc">TOC</A></FONT></B> ]
<HR>
<H2><A NAME="Indexing_Command_Line_Arguments">Indexing Command Line Arguments</A></H2>
<DL>
<P><DT><STRONG><A NAME="item__i">-i *directories and/or files* (input file)</A></STRONG><DD>
<P>
This specifies the directories and/or files to index. Directories will be
indexed recursively. This is typically specified in the <A HREF="././SWISH-CONFIG.html">configuration file</A> with the <STRONG>IndexDir</STRONG> directive instead of on the command line. Use of this switch overrides the
configuration file settings.
<P><DT><STRONG><A NAME="item__S">-S [fs|http|prog] (document source/access mode)</A></STRONG><DD>
<P>
This specifies the method to use for accessing documents to index. Can be
either <A HREF="#item_fs">fs</A> for local indexing via the file system (the default),
<A HREF="#item_http">http</A> for spidering, or <A HREF="#item_prog">prog</A> for reading documents from an external program.
<P>
Located in the <CODE>conf</CODE> directory are example configuration files that demonstrate indexing with
the different document source methods.
<P>
See the <A HREF="././SWISH-FAQ.html">SWISH-FAQ</A> for a discussion on the different indexing methods, and the difference
between spidering with the http method vs. using the file system method.
<DL>
<P><DT><STRONG><A NAME="item_fs">fs - file system</A></STRONG><DD>
<P>
The <A HREF="#item_fs">fs</A> method simply reads files from a local (or networked) drive. This is the
default method if the <CODE>-S</CODE> switch is not specified. See <A HREF="././SWISH-CONFIG.html">SWISH-CONFIG</A> for configuration directives specific to the <A HREF="#item_fs">fs</A> method.
<P><DT><STRONG><A NAME="item_http">http - spider a web server</A></STRONG><DD>
<P>
The <A HREF="#item_http">http</A> method is used to spider web servers. It uses an included helper program
called <EM>swishspider</EM>. See <A HREF="././SWISH-CONFIG.html">SWISH-CONFIG</A> for configuration directives specific to the <A HREF="#item_http">http</A> method.
<P>
Security Note: Under Windows swish passes the URLs fetched from remote
documents through the shell (swish uses the <CODE>system()</CODE> command
for running <EM>swishspider</EM> under Windows), and this may be considered an additional security risk.
<P>
The <A HREF="#item_http">http</A> method is deprecated (or at least not very well appreciated). Consider
using the <A HREF="#item_prog">prog</A> method described below for spidering. There's a spider program available in
the
<EM>prog-bin</EM> directory for use with the <A HREF="#item_prog">prog</A> method. Here's a number of limitation with this method that are solved with
the <A HREF="#item_prog">prog</A> method:
<UL>
<P><LI>
<P>
swishspider only spiders standard <a href="..."> links. Frames and other links are not followed.
<P><LI>
<P>
By default, this method of spidering only indexes files that have a content
type of "text/*" (e.g. text/plain, text/html, text/xml). You
should use <A HREF="#item_DefaultContents">DefaultContents</A> and <A HREF="#item_IndexContents">IndexContents</A> to map file extensions to parsers used by swish (e.g. <CODE>IndexContents HTML* .html .htm</CODE>), but this will fail where a document does not have a file extension.
<P><LI>
<P>
Swish-e's <A HREF="#item_FileFilter">FileFilter</A> directive can be used with the <A HREF="#item_http">http</A> access method, although it requires a separate process (in addition to the
swsihspider process) for each document filtered.
<P><LI>
<P>
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 PERL5LIB to point to
the location of the SWISH module name space (typically
/usr/local/lib/swish-e under Unix). For example:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> export PERL5LIB=/usr/local/lib/swish-e # bash, bourne shells
setenv PERL5LIB /usr/local/lib/swish-e # csh, tcsh</pre>
</td>
</tr>
</table>
<P>
or under Windows
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> set PERL5LIB=c:\program files\swish-e2.4\lib\swish-e</pre>
</td>
</tr>
</table>
<P>
SWISH::Filter is not enabled by default due to the overhead of loading the
modules for every document fetched.
<P>
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
<EM>swishspider</EM> will use these modules if can be found via PERL5LIB. These modules only
provide an interface to programs that do the conversion. For example, you
will need to download and install the "catdoc" program to convert
MSWord documents into text for indexing. Please see
<EM>filters/README</EM> to see how to use this filter system.
</UL>
<P><DT><STRONG><A NAME="item_prog">prog - general purpose access method</A></STRONG><DD>
<P>
The <A HREF="#item_prog">prog</A> 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.
<P>
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 <CODE>-S fs</CODE>), yet provide you with full control of what files are indexed.
<P>
The external program name to run is passed to swish either by the
<A HREF="././SWISH-CONFIG.html#item_IndexDir">IndexDir</A> directive, or via the <CODE>-i</CODE> option.
<P>
The program specified should be an absolute path as swish-e will attempt to
<CODE>stat()</CODE> the program to make sure it exists. Swish does this to
help in error reporting.
<P>
If the program specified with -i or IndexDir is not an absolute path (i.e.
does not include "/" ) then swish-e will append the
"libexecdir" directory defined during configuration. Typically,
libexecdir is set to "$prefix/lib/swish-e"
(/usr/local/lib/swish-e), but is platform and installation dependent.
Running swish-e -h will report the directory.
<P>
For example, the -S prog program "spider.pl" is a Perl helper
program for use with -S prog and is installed in libexecdir.
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> IndexDir spider.pl
SwishProgParameters default <A HREF="http://localhost/index.html">http://localhost/index.html</A></pre>
</td>
</tr>
</table>
<P>
and swish-e will find spider.pl in libexecdir.
<P>
Additional parameters may be passed to the external program via the
<A HREF="././SWISH-CONFIG.html#item_SwishProgParameters">SwishProgParameters</A> directive. In the example above swish-e will pass two parameters to
spider.pl, "default" and "http://localhost/index.html".
<P>
A special name "stdin" may be used with <CODE>-i</CODE> or <A HREF="././SWISH-CONFIG.html#item_IndexDir">IndexDir</A>
which tells swish to read from standard input instead of from an external
program. See example below.
<P>
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 HTTP document returned by a web server in
that it includes name/value pairs of headers, a blank line, and the
content.
<P>
The content length is determined by a content-length header supplied to
swish by the program; there is no "end of record" character or
flag sent between documents. Therefore, it is critical that the
content-length header is correct. This is a common source of errors.
<P>
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.
<P>
Here's a simple example written in Perl:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> #!/usr/local/bin/perl -w
use strict;</pre>
</td>
</tr>
</table>
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> # Build a document
my $doc = <<EOF;
<html>
<head>
<title>Document Title</title>
</head>
<body>
This is the text.
</body>
</html>
EOF</pre>
</td>
</tr>
</table>
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> # Prepare the headers for swish
my $path = 'Example.file';
my $size = length $doc;
my $mtime = time;</pre>
</td>
</tr>
</table>
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> # Output the document (to swish)
print <<EOF;
Path-Name: $path
Content-Length: $size
Last-Mtime: $mtime
Document-Type: HTML*</pre>
</td>
</tr>
</table>
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> EOF</pre>
</td>
</tr>
</table>
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> print $doc;</pre>
</td>
</tr>
</table>
<P>
The external program passes to swish a header. The header is separated from
the body of the document with a blank line. The available headers are:
<DL>
<P><DT><STRONG><A NAME="item_Path">Path-Name:</A></STRONG><DD>
<P>
This is the name of the file you are indexing. This can be any string, so
for example it could be an ID of a record in a database, a URL or a simple
file name.
<P>
This header is required.
<P><DT><STRONG><A NAME="item_Content">Content-Length:</A></STRONG><DD>
<P>
This header specifies the length in bytes of the document that follows the
header. This length must be exactly the length of the document -- do not
make the mistake of adding an extra line feed at the end of the document.
<P>
This header is required.
<P><DT><STRONG><A NAME="item_Last">Last-Mtime:</A></STRONG><DD>
<P>
Thi parameter is the last modification time of the file, and must be a time
stamp (seconds since the Epoch on your platform).
<P>
This header is not required.
<P><DT><STRONG><A NAME="item_Document">Document-Type:</A></STRONG><DD>
<P>
You may override swish's determination of document type (<CODE>Indexcontents</CODE>) by using the <CODE>Document-Type:</CODE> header. The document type is used to select which parser Swish-e uses to
parse the document's contents.
<P>
For example, a spider program might map the content-type returned from a
web server to one of the types Swish-e understands. For example,
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> my $doc_type = 'HTML*' if $response->content_type =~ m!text/html!'</pre>
</td>
</tr>
</table>
<P>
This header is not required.
</DL>
<P>
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 XML, HTML, or text, and pass them to
swish, one after another. The <CODE>Content-Length:</CODE> header tells swish where each document ends -- there is not any special
"end of record" character or marker.
<P>
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 <A HREF="#item_prog">prog</A>
mode, and the name of the program to use for input.
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> % chmod 755 example.pl
% ./swish-e -S prog -i ./example.pl</pre>
</td>
</tr>
</table>
<P>
Programs can and should be tested prior to running swish. For example:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> % ./example.pl > test.out</pre>
</td>
</tr>
</table>
<P>
A few more useful example programs are provided in the swish-e distribution
located in the <EM>prog-bin</EM> directory. Some include documentation:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> % cd prog-bin
% perldoc spider.pl</pre>
</td>
</tr>
</table>
<P>
Others are small examples that include comments:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> % cd prog-bin
% less DirTree.pl</pre>
</td>
</tr>
</table>
<P>
The <EM>spider.pl</EM> program can be used as a replacement for the <EM>-S http</EM> method. It is far more feature-rich and offers much more control over
indexing.
<P>
If you use the special program name "stdin" with <CODE>-i</CODE> or <A HREF="././SWISH-CONFIG.html#item_IndexDir">IndexDir</A>
then swish-e will read from standard input instead of from a program. For
example:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> % ./example.pl --count=1000 /path/to/data | ./swish-e -S prog -i stdin</pre>
</td>
</tr>
</table>
<P>
This is basically the same as using a swish-e configuration file of:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> SwishProgParameters --count=1000 /path/to/data
IndexDir ./example.pl</pre>
</td>
</tr>
</table>
<P>
in a config file and running
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> % ./swish-e -S prog -c swish.conf</pre>
</td>
</tr>
</table>
<P>
This gives an easy way to run swish without a configuration file with a <CODE>-S prog</CODE> program that requires parameters. It also means you can capture data to a
file and then index more once with the same data:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> % ./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</pre>
</td>
</tr>
</table>
<P>
Using "stdin" might also be useful for programs that call swish
(instead of swish calling the program).
<P>
(The reason "stdin" is used instead of the more common
"-" dash is due to the rotten way swish parses the command line.
This should be fixed in the future.)
<P>
The <A HREF="#item_prog">prog</A> method bypasses some of the configuration parameters available to the file
system method -- settings such as
<A HREF="#item_IndexOnly">IndexOnly</A>, <A HREF="#item_FileRules">FileRules</A>, <A HREF="#item_FileMatch">FileMatch</A> and <A HREF="#item_FollowSymLinks">FollowSymLinks</A>
are ignored when using the <A HREF="#item_prog">prog</A> 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 <A HREF="#item_prog">prog</A> method, only send the documents to swish that you want indexed.
<P>
You may use swish's filter feature with the <A HREF="#item_prog">prog</A> method, but performance will be better if you run filtering programs from
within your external program. See also <EM>filters/README</EM> for an example how to easily add document converstion and filtering into
your Perl-based programs.
<P>
<STRONG>Notes when using -S prog on MS Windows</STRONG>
<P>
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
<A HREF="#item_SwishProgParameters">SwishProgParameters</A> to name the file.
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> IndexDir e:/perl/bin/perl.exe
SwishProgParameters read_database.pl</pre>
</td>
</tr>
</table>
<P>
Swish will replace the forward slashes with backslashes before running the
command specified with
<A HREF="#item_IndexDir">IndexDir</A>. Swish uses the <CODE>popen(3)</CODE> command which passes the command
through the shell.
</DL>
<P><DT><STRONG><A NAME="item__f">-f *indexfile* (index file)</A></STRONG><DD>
<P>
If you are indexing, this specifies the file to save the generated index
in, and you can only specify one file. See also <STRONG>IndexFile</STRONG> in the <A HREF="././SWISH-CONFIG.html">configuration file</A>.
<P>
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.
<P><DT><STRONG><A NAME="item__c">-c *file ...* (configuration files)</A></STRONG><DD>
<P>
Specify the configuration <CODE>file(s)</CODE> to use for indexing. This
file contains many directives that control how Swish-e proceeds. See <A HREF="././SWISH-CONFIG.html">SWISH-CONFIG</A> for a complete listing of configuration file directives.
<P>
Example:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> swish-e -c docs.conf</pre>
</td>
</tr>
</table>
<P>
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.
<P>
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.
<P>
Examples:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> 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</pre>
</td>
</tr>
</table>
<OL>
<P><LI>
<P>
The settings in the configuration file will be used to index a site.
<P><LI>
<P>
These command-line options will override anything in the configuration
file.
<P><LI>
<P>
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.
</OL>
<P><DT><STRONG><A NAME="item__e">-e (economy mode)</A></STRONG><DD>
<P>
For large sites indexing may require more RAM than is available. The <CODE>-e</CODE> switch tells swish to use disk space to store data structures while
indexing, saving memory. This option is recommended if swish uses so much
RAM 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.
<P><DT><STRONG><A NAME="item__l">-l (symbolic links)</A></STRONG><DD>
<P>
Specifying this option tells swish to follow symbolic links when indexing.
The configuration file value <STRONG>FollowSymLinks</STRONG> will override the command-line value.
<P>
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.
<P><DT><STRONG><A NAME="item__N">-N path (index only newer files)</A></STRONG><DD>
<P>
The <CODE>-N</CODE> option takes a path to a file, and only files <EM>newer</EM> 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.
<P>
Example (bad example)
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> swish-e -c config.file -N index.swish-e -f index.new</pre>
</td>
</tr>
</table>
<P>
This will index as normal, but only files with a modified date newer than <EM>index.swish-e</EM> will be indexed.
<P>
This is a bad example because it uses <EM>index.swish-e</EM> 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 <EM>index.swish-e</EM> file was created -- which can be quite a bit of time for very large
indexing jobs.
<P>
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:
<P>
Full indexing:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> touch indexing_time.file
swish-e -c config.file -f index.tmp
mv index.tmp index.full</pre>
</td>
</tr>
</table>
<P>
Incremental indexing:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> swish-e -c config.file -N indexing_time.file -f index.tmp
mv index.tmp index.incremental</pre>
</td>
</tr>
</table>
<P>
Then search with
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> swish-e -w foo -f index.full index.incremental</pre>
</td>
</tr>
</table>
<P>
or merge the indexes
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> swish-e -M index.full index.incremental index.tmp
mv index.tmp index.swish-e
swish-e -w foo</pre>
</td>
</tr>
</table>
<P><DT><STRONG><A NAME="item__v">-v [0|1|2|3] (verbosity level)</A></STRONG><DD>
<P>
The <CODE>-v</CODE> option can take a numerical value from 0 to 3. Specify 0 for completely
silent operation and 3 for detailed reports.
<P>
If no value is given then 1 is assumed. See also <STRONG>IndexReport</STRONG> in the <A HREF="././SWISH-CONFIG.html">configuration file</A>.
<P>
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).
</DL>
<P>
[ <B><FONT SIZE=-1><A HREF="#toc">TOC</A></FONT></B> ]
<HR>
<H1><A NAME="SEARCHING">SEARCHING</A></H1>
<P>
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.
<P>
This section just lists the available command line arguments and their
usage. Please see <A HREF="././SWISH-SEARCH.html">SWISH-SEARCH</A> for detailed searching instructions.
<P>
<STRONG>Warning</STRONG>: If using Swish-e via a CGI interface, please see <A HREF="././SWISH-SEARCH.html#CGI_Danger_">CGI Danger!</A>
<P>
Security Note: If the swish binary is named <EM>swish-search</EM> then swish will not allow any operation that would cause swish to write to
the index file.
<P>
[ <B><FONT SIZE=-1><A HREF="#toc">TOC</A></FONT></B> ]
<HR>
<H2><A NAME="Searching_Command_Line_Arguments">Searching Command Line Arguments</A></H2>
<DL>
<P><DT><STRONG><A NAME="item__w">-w *word1 word2 ...* (query words)</A></STRONG><DD>
<P>
This performs a case-insensitive search using a number of keywords. If no
index file to search is specified (via the <CODE>-f</CODE> switch), swish-e will try to search a file called index.swish-e in the
current directory.
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> swish-e -w word</pre>
</td>
</tr>
</table>
<P>
Phrase searching is accomplished by placing the quote delimiter (a
double-quote by default) around the search phrase.
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> swish-e -w 'word or "this phrase"'</pre>
</td>
</tr>
</table>
<P>
Search would should be protected from the shell by quotes. Typically, this
is single quotes when running under Unix.
<P>
Under Windows <EM>command.com</EM> you may not need to use quotes, but you will need to backslash the quotes
used to delimit phrases:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> swish-e -w \"a phrase\"</pre>
</td>
</tr>
</table>
<P>
The phrase delimiter can be set with the <CODE>-P</CODE> switch.
<P>
The search may be limited to a <EM>MetaName</EM>. For example:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> swish-e -w meta1=(foo or baz)</pre>
</td>
</tr>
</table>
<P>
will only search within the <STRONG>meta1</STRONG> tag.
<P>
Please see <A HREF="././SWISH-SEARCH.html">SWISH-SEARCH</A> for a description of MetaNames
<P><DT><STRONG>-f *file1 file2 ...* (index files)</STRONG><DD>
<P>
Specifies the index <CODE>file(s)</CODE> used while searching. More than
one file may be listed, and each file will be searched. If no <CODE>-f</CODE> switch is specified then the file <EM>index.swish-e</EM> in the current directory will be used as the index file.
<P><DT><STRONG><A NAME="item__m">-m *number* (max results)</A></STRONG><DD>
<P>
While searching, this specifies the maximum number of results to return.
The default is to return all results.
<P>
This switch is often used in conjunction with the <CODE>-b</CODE> switch to return results one page at a time (strongly recommended for large
indexes).
<P><DT><STRONG><A NAME="item__b">-b *number* (beginning result)</A></STRONG><DD>
<P>
Sets the <EM>begining</EM> search result to return (records are numbered from 1). This switch can be
used with the <CODE>-m</CODE> switch to return results in groups or pages.
<P>
Example:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> swish-e -w 'word' -b 1 -m 20 # first 'page'
swish-e -w 'word' -b 21 -m 20 # second 'page'</pre>
</td>
</tr>
</table>
<P><DT><STRONG><A NAME="item__t">-t HBthec (context searching)</A></STRONG><DD>
<P>
The <CODE>-t</CODE> option allows you to search for words that exist only in specific HTML
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 HEAD tags, B stands for BODY tags, t is all TITLE tags, h is H1 to H6
(header) tags, e is emphasized tags (this may be B, I, EM, or STRONG), and
c is HTML comment tags
<P>
search only in header (<H*>) tags
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> swish-e -w word -t h</pre>
</td>
</tr>
</table>
<P><DT><STRONG><A NAME="item__d">-d *string* (delimiter)</A></STRONG><DD>
<P>
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 <CODE>-d</CODE> to specify a character or string used as a separator between fields.
<P>
The string <CODE>dq</CODE> means "double-quotes".
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> 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 \" # double quotes under Windows
swish-e -w word -d dq # double quotes</pre>
</td>
</tr>
</table>
<P>
The following control characters may also be specified: <CODE>\t \r \n \f</CODE>.
<P>
Warning: This string is passed directly to <CODE>sprintf()</CODE> and
therefore exposes a securty hole. Do not allow user data to set -d format
strings directly.
<P><DT><STRONG><A NAME="item__P">-P *character*</A></STRONG><DD>
<P>
Sets the delimiter used for phrase searches. The default is double quotes <CODE>"</CODE>.
<P>
Some examples under bash: (be careful about you shell metacharacters)
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> swish-e -P ^ -w 'title=^words in a phrase^'
swish-e -P \' -w "title='words in a pharse"'</pre>
</td>
</tr>
</table>
<P><DT><STRONG><A NAME="item__p">-p *property1 property2 ...* (display properties)</A></STRONG><DD>
<P>
This causes swish to print the listed property in the search results. The
properties are returned in the order they are listed in the <CODE>-p</CODE> argument.
<P>
Properties are defined by the <STRONG>ProperNames</STRONG> directive in the configuration file (see <A HREF="././SWISH-CONFIG.html">SWISH-CONFIG</A>) and properties must also be defined in <STRONG>MetaNames</STRONG>. Swish stores the text of the meta name as a <EM>property</EM>, and then will return this text while searching if this option is used.
<P>
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 <STRONG>Document Summeries</STRONG> and <A HREF="././SWISH-CONFIG.html#item_PropertyNames">PropertyNames</A> in <A HREF="././SWISH-CONFIG.html">SWISH-CONFIG</A>.
<P>
To return the subject and category properties while indexing.
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> swish-e -w word -p subject category</pre>
</td>
</tr>
</table>
<P>
Properties are returned in double quotes. If a property contains a double
quote it is HTML escaped ("). See the <CODE>-x</CODE> switch for a more advanced method of returning a list of properties.
<P>
NOTE: it is necessary to have indexed with the proper PropertyNames
directive in the user config file in order to use this option.
<P><DT><STRONG><A NAME="item__s">-s *property [asc|desc] ...* (sort)</A></STRONG><DD>
<P>
Normally, search results are printed out in order of relevancy, with the
most relevant listed first. The <CODE>-s</CODE> sort switch allows you to sort results in order of a specified <EM>property</EM>, where a <EM>property</EM>
was defined using the <STRONG>MetaNames</STRONG> and <STRONG>PropertyNames</STRONG> directives during indexing (see <A HREF="././SWISH-CONFIG.html">SWISH-CONFIG</A>).
<P>
The string passed can include the strings <CODE>asc</CODE> and <CODE>desc</CODE> to specify the sort order, and more than one property may be specified to
sort on more than one key.
<P>
Examples:
<P>
sort by title property ascending order
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> -s title</pre>
</td>
</tr>
</table>
<P>
sort descending by title, ascending by name
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> -s title desc name asc</pre>
</td>
</tr>
</table>
<P>
Note: Swish limits sort keys to 100 characters. This limit can be changed
by changing MAX_SORT_STRING_LEN in src/config.h and rebuilding swish-e.
<P><DT><STRONG><A NAME="item__L">-L limit to a range of property values (Limit)</A></STRONG><DD>
<P>
<STRONG>This is an experimental feature!</STRONG>
<P>
The <CODE>-L</CODE> switch can be used to limit search results to a range of property values
<P>
Example:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> swish-e -w foo -L swishtitle a m</pre>
</td>
</tr>
</table>
<P>
finds all documents that contain the word <CODE>foo</CODE>, and where the document's title is in the range of <CODE>a</CODE> to <CODE>m</CODE>, inclusive. By default, the case of the property is ignored, but this can
be changed by using <A HREF="././SWISH-CONFIG.html#item_PropertyNamesCompareCase">PropertyNamesCompareCase</A>
configuation directive.
<P>
Limiting may be done with user-defined properties, as well.
<P>
For example, if you indexed documents that contain a created timestamp in a
meta tag:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> <meta name="created_on" content="982648324"></pre>
</td>
</tr>
</table>
<P>
Then you tell Swish that you have a property called <CODE>created_on</CODE>, and that it's a timestamp.
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> PropertyNamesDate created_on</pre>
</td>
</tr>
</table>
<P>
After indexing you will be able to limit documents to a range of
timestamps:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> -w foo -L created_on 946684800 949363199</pre>
</td>
</tr>
</table>
<P>
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.
<P>
Note: swish currently does not parse dates; Unix timestamps must be used.
<P>
Two special formats can be used:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> -L swishtitle <= m
-L swishtitle >= m</pre>
</td>
</tr>
</table>
<P>
Finds titles less than or equal, or grater than or equal to the letter <CODE>m</CODE>.
<P>
This feature will not work with <CODE>swishrank</CODE> or <CODE>swishdbfile</CODE> properties.
<P>
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:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> 6 properties sorted.</pre>
</td>
</tr>
</table>
<P>
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 <A HREF="#item_PreSortedIndex">PreSortedIndex</A>.
<P>
Using the <CODE>-L</CODE> switch on a property that was not pre-sorted will still work, but may be <EM>much</EM>
slower during searching.
<P>
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.
<P>
This is an experimental feature, and its use and interface are subject to
change.
<P><DT><STRONG><A NAME="item__x">-x formatstring (extended output format)</A></STRONG><DD>
<P>
The <CODE>-x</CODE> 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 <CODE>-d</CODE> and
<CODE>-p</CODE>, and a warning will be generated if <CODE>-d</CODE> or <CODE>-p</CODE> are used with <CODE>-x</CODE>.
<P>
Warning: The format string (fmt) is passed directly to
<CODE>sprintf()</CODE> and therefore exposes a securty hole. Do not allow
user data to set -x format strings directly.
<P>
For example, to return just the title, one per line, in the search results:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> swish-e -w ... -x '<swishtitle>\n' ...</pre>
</td>
</tr>
</table>
<P>
Note: the <CODE>\n</CODE> may need to be protected from your shell.
<P>
See also <A HREF="././SWISH-CONFIG.html#item_ResultExtFormatName">ResultExtFormatName</A> for a way to define <EM>named</EM>
format strings in the swish configuration file.
<P>
<STRONG>Format of "formatstring":</STRONG>
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> "text<propertyname>text<propertyname fmt=propfmtstr>text..."</pre>
</td>
</tr>
</table>
<P>
Where <STRONG>propertyname</STRONG> is:
<UL>
<P><LI>
<P>
the name of a user property as specified with the config file directive
"PropertyNames"
<P><LI>
<P>
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.)
</UL>
<P>
propertynames must be placed within "<" and ">".
<P>
<STRONG>User properties:</STRONG>
<P>
Swish-e allows you to specify certain META tags within your documents that
can be used as <STRONG>document properties</STRONG>. The contents of any META 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 <STRONG>PropertyNames</STRONG>
configuration directive (see <A HREF="././SWISH-CONFIG.html#item_PropertyNames">SWISH-CONFIG</A>).
<P>
Examples of user-defined PropertyNames:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> <keywords>
<author>
<deliveredby>
<reference>
<id></pre>
</td>
</tr>
</table>
<P>
<STRONG>Auto properties:</STRONG>
<P>
Swish defines a number of "Auto" properties for each document
indexed. These are available for output when using the <CODE>-x</CODE> format.
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> 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</pre>
</td>
</tr>
</table>
<P>
The Auto properties can also be specified using shortcuts:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> Shortcut Property Name
-------- --------------
%c swishreccount
%d swishdescription
%D swishlastmodified
%I swishdbfile
%p swishdocpath
%r swishrank
%l swishdocsize
%t swishtitle</pre>
</td>
</tr>
</table>
<P>
For example, these are equivalent:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> -x '<swishrank>:<swishdocpath>:<swishtitle>\n'
-x '%r:%p:%t\n'</pre>
</td>
</tr>
</table>
<P>
Use a double percent sign "%%" to enter a literal percent sign in
the output.
<P>
<STRONG>Formatstrings of properties:</STRONG>
<P>
Properties listed in an <CODE>-x</CODE> format string can include format control strings. These
"propertyformats" 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
"fmt" within the property tag.
<P>
Format strings cannot be used with the "%" shortcuts described
above.
<P>
General syntax:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> -x '<propertyname fmt="propfmtstr">'</pre>
</td>
</tr>
</table>
<P>
where <CODE>subfmt</CODE> controls the output format of <CODE>propertyname</CODE>.
<P>
Examples of property format strings:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> date type: <swishlastmodified fmt="%d.%m.%Y">
string type: <swishtitle fmt="%-40.35s">
integer type: <swishreccount fmt=/%8.8d/></pre>
</td>
</tr>
</table>
<P>
Please see the manual pages for <CODE>strftime(3)</CODE> and
<CODE>sprintf(3)</CODE> for an explanation of format strings. Note: some
versions of strftime do not offer the <CODE>%s</CODE> format string (number
of seconds since the Epoch), so swish provides a special format string
"%ld" to display the number of seconds since the Epoch.
<P>
The first character of a property format string defines the delimiter for
the format string. For example,
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> -x "<author fmt=[%20s]> ...\n"
-x "<author fmt='%20s'> ...\n"
-x "<author fmt=/%20s/> ...\n"</pre>
</td>
</tr>
</table>
<P>
<STRONG>Standard predefined formats:</STRONG>
<P>
If you ommit the sub-format, the following formats are used:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> 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)</pre>
</td>
</tr>
</table>
<P>
<STRONG>Text in "formatstring" or "propfmtstr":</STRONG>
<P>
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 "\n"
at the end of "fmtstr".
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> -x "<swishreccount>|<swishrank>|<swishdocpath>\n"
-x "Count=<swishreccount>, Rank=<swishrank>\n"
-x "Title=\<b\><swishtitle>\</b\>"
-x 'Date: <swishlastmodified fmt="%m/%d/%Y">\n'
-x 'Date in seconds: <swishlastmodified fmt=/%ld/>\n'</pre>
</td>
</tr>
</table>
<P>
<STRONG>Control/Escape charcters:</STRONG>
<P>
you can use C-like control escapes in the format string:
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> known controls: \a, \b, \f, \n, \r, \t, \v,
digit escapes: \xhexdigits \0octaldigits
character escapes: \anychar </pre>
</td>
</tr>
</table>
<P>
Example,
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> swish -x "%c\t%r\t%p\t\"<swishtitle fmt=/%40s/>\"\n"</pre>
</td>
</tr>
</table>
<P>
<STRONG>Examples of -x format strings:</STRONG>
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> -x "%c|%r|%p|%t|%D|%d\n"
-x "%c|%r|%p|%t|<swishdate fmt=/%A, %d. %B %Y/>|%d\n"
-x "<swishrank>\t<swishdocpath>\t<swishtitle>\t<keywords>\n
-x "xml_out: \<title\><swishtitle>\>\</title\>\n"
-x "xml_out: <swishtitle fmt='<title>%s</title>'>\n"</pre>
</td>
</tr>
</table>
<P><DT><STRONG><A NAME="item__H">-H [0|1|2|3|<n>] (header output verbosity)</A></STRONG><DD>
<P>
The <CODE>-H n</CODE> switch generates extened <EM>header</EM> output. This is most useful when searching more than one index file at a
time by specifying more than one index file with the <CODE>-f</CODE> switch.
<CODE>-H 2</CODE> will generate a set of headers specific to each index file. This gives
access to the settings used to generate each index file.
<P>
Even when searching a single index file, <CODE>-H n</CODE> will provided additional information about the index file, how it was
indexed, and how swish is interperting the query.
<P>
<table>
<tr>
<td bgcolor="#eeeeee" width="1">
</td>
<td>
<pre> -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>)</pre>
</td>
</tr>
</table>
<P><DT><STRONG><A NAME="item__R">-R [0|1] (Ranking Scheme)</A></STRONG><DD>
<P>
<STRONG>This is an experimental feature!</STRONG>
<P>
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.
<P>
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 (IDF), 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.
<P>
<STRONG>NOTE:</STRONG> IgnoreTotalWordCountWhenRanking must be set to <STRONG>no</STRONG> or <STRONG>0</STRONG> in your <CODE>index(es)</CODE> for -R 1 to work.
<P>
Specify -R 1 to turn on IDF ranking. See the API documentation for how to
set the ranking scheme in your Perl or C program.
</DL>
<P>
[ <B><FONT SIZE=-1><A HREF="#toc">TOC</A></FONT></B> ]
<HR>
<H1><A NAME="OTHER_SWITCHES">OTHER SWITCHES</A></H1>
<DL>
<P><DT><STRONG><A NAME="item__V">-V (version)</A></STRONG><DD>
<P>
Print the current version.
<P><DT><STRONG><A NAME="item__k">-k *letter* (print out keywords)</A></STRONG><DD>
<P>
The <CODE>-k</CODE> switch is used for testing and will cause swish to print out all keywords
in the index beginning with that letter. You may enter <CODE>-k '*'</CODE> to generate a list of all words indexed by swish.
<P><DT><STRONG><A NAME="item__D">-D *index file* (debug index)</A></STRONG><DD>
<P>
The -D option is no longer supported in version 2.2.
<P><DT><STRONG><A NAME="item__T">-T *options* (trace/debug swish)</A></STRONG><DD>
<P>
The -T option is used to print out information that may be helpful when
debugging swish-e's operation. This option replaced the <CODE>-D</CODE> option of previous versions.
<P>
Running <CODE>-T help</CODE> will print out a list of available *options*
</DL>
<P>
[ <B><FONT SIZE=-1><A HREF="#toc">TOC</A></FONT></B> ]
<HR>
<H1><A NAME="Merging_Index_Files">Merging Index Files</A></H1>
<P>
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.
<P>
Indexing is much faster now and uses much less memory, and with the <CODE>-e</CODE> switch very little memory is needed to index a large site.
<P>
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.
<DL>
<P><DT><STRONG><A NAME="item__M">-M *index1 index2 ... indexN out_index</A></STRONG><DD>
<P>
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).
<P>
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.).
<P>
Use the <CODE>-e</CODE> switch while merging to reduce memory usage.
<P>
Merge generates progress messages regardless of the setting of <CODE>-v</CODE>.
<P><DT><STRONG>-c *configuration file*</STRONG><DD>
<P>
Specify a configuration file while indexing to add administrative
information to the output index file.
</DL>
<P>
[ <B><FONT SIZE=-1><A HREF="#toc">TOC</A></FONT></B> ]
<HR>
<H1><A NAME="Document_Info">Document Info</A></H1>
<P>
$Id: SWISH-RUN.pod,v 1.35 2004/08/31 03:15:03 karman Exp $
<P>
.
[ <B><FONT SIZE=-1><A HREF="#toc">TOC</A></FONT></B> ]
<HR>
<p>
<div class="navbar">
<a href="./SWISH-CONFIG.html">Prev</a> |
<a href="./index.html">Contents</a> |
<a href="./SWISH-SEARCH.html">Next</a>
</div>
<p>
<P ALIGN="CENTER">
<IMG ALT="" WIDTH="470" HEIGHT="10" SRC="images/dotrule1.gif"></P>
<P ALIGN="CENTER">
<div class="footer">
<BR>SWISH-E is distributed with <B>no warranty</B> under the terms of the
<A HREF="http://www.fsf.org/copyleft/gpl.html">GNU Public License</A>,<BR>
Free Software Foundation, Inc.,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA<BR>
Public questions may be posted to
the <A HREF="http://swish-e.org/Discussion/">SWISH-E Discussion</A>.
</div>
</body>
</html>
|