Frontend is a part of the search system installed on the server and performing search in the index file. There are three files necessary for the Frontend to work:
Typically the Frontend (file 'search.cgi' or 'search.exe') can be found in '/cgi-bin' directory and the web-server must have a permission to execute it. In the same directory there should be three files created by the Indexer. They are listed above.
The search word is delivered as a value of 'q' parameter. For example:
http://www.site.ru/cgi-bin/search.cgi?q=find+this
Hence, you can create search form according to you wish. The simplest variant looks like this:
<form action="/cgi-bin/search.cgi" method="get"> <input type="text" name="q" value=""> <input type="submit" value="Search"> </form>
File 'fulltxt.cns' may be of a considerable size, it contains texts of all indexed documents. This information allows to show text samples containing highlighted search words and phrases in search results. For example:
File 'fulltxt.cns' may be deleted or simply not created (see parameter Type in configuration file 'search.conf') during indexing process, and in such case the search results will look as follows (without highlighting and citing, just first 256 symbols of document are displayed):
The frontend configuration file (by default cnsearch.conf) should be stored in the same directory with the file 'search.cgi'. It is a text file specially optimized for fast processing. It has two parts:
The structure of the configuration file looks as follows:
::CONFIG regcode = Enter Your registration code here ::CONFIG stats = password ::CONFIG content-type = text/html ::HTMLTOP <HTML><TITLE>This is the top part of the HTML document</TITLE></HEAD><BODY> ::HTMLRESULT <P>This the description of the found page. There will be displayed 10 such descriptions. ::HTMLNOTFOUND <P>This text will be displayed if no search results will be found ::HTMLBOTTOM This is the bottom part of the HTML document </BODY> </HTML>
You may use single-line commentaries in the configuration file. Each commentary starts with symbol "#".
The configuration part contains parameters placed by one on a line. More information about these parameters can be found below.
The template part contains HTML code generating HTML-document with the search results. It is necessary to use special symbols within this code, which will be replaced by corresponding text when the HTML document is generated:
-- cnsearch.conf ---------------------------------------- # This is a cnsearch configuration file ::CONFIG regcode = Enter Your registration code here ::CONFIG stats = password ::CONFIG content-type = text/html ::CONFIG NonStrictMatch = [non strict match] ::CONFIG StopWords =, Ignored Words : ::CONFIG SearchType = Combined ::HTMLTOP <HTML> <HEAD> <TITLE>Search results - %Q</TITLE> </HEAD> <BODY> <table width=400 height=40 align=center bgcolor=#C0C0C0> <form action="%F" method=get><tr><td align=center> <input type=text name=q size=40 maxlength=64 value="%Q"> <input type=submit value="Search"> </td></form></tr></table> Documents found: %O <B>%O</B><font color=gray>%W<B>%P</B></font><br> <br> <div align=right> Sort by: <a href="%A">date</a> | <a href="%L">relevancy</a> </div> ::HTMLRESULT <HR> <UL> <LI>%N. <a href="%U" target=_new>%T</A> <small> <font color=red>%S</font> [Relevancy: %R]</small> <UL> <LI>%E <LI>%D <LI>%C <LI><a href="%U" target=_new>%u</A> </UL> </UL> ::HTMLNOTFOUND <P><font color=red>%Q not found</font> ::HTMLBOTTOM %B </BODY> </HTML> -- end cnsearch.conf ------------------------------------
You may use several templates by setting 'template' in the search form. If 'template' is not specified, file 'search.htm' is used.
You may set a different name for a template. Name of a template must contain only upper or lower-case Latin letters and figures. It is not necessary to add '.htm' to the file name.
Correct variant:
<input type=hidden value='black'> <input type=hidden value='red'>
Incorrect variant:
<input type=hidden value='../black'> <input type=hidden value='red.htm'>
Below you can see an example of the template, allowing user to select an index, where search will be performed. Note - this result may be achieved by use of 'template' with template parameter path.
This example shows how several configuration files may can be used to create differently looking designs and search indexes.
The following path to the index files is used in the template:
::CONFIG path=/home/www/search/en
Name of the frontend configuration file to be used during the search process is handled from the search form by means of the template parameter. In the example below these are files en.conf, es.conf, and ru.conf.
-- en.conf --------------------------------------------- ::CONFIG path=/home/www/search/en ::CONFIG regcode = Enter Your registration code here ::CONFIG stats = password ::CONFIG content-type = text/html ::CONFIG NonStrictMatch = [non strict match] ::CONFIG StopWords =, Ignored Words : ::CONFIG SearchType = Combined ::HTMLTOP <HTML> <HEAD> <TITLE>Search results - %Q</TITLE> </HEAD> <BODY> <table width=400 height=40 align=center bgcolor=#C0C0C0> <form action="%F" method=get><tr><td align=center> <input type=text name=q size=40 maxlength=64 value="%Q"> <input type=submit value="Search"> <select name=template> <option value="en">English <option value="es">Spanish <option value="ru">Russian </select> </td></form></tr></table> Documents found: %O <B>%O</B><font color=gray>%W<B>%P</B></font><br> <br> <div align=right> Sort by: <a href="%A">date</a> | <a href="%L">relevancy</a> </div> ::HTMLRESULT <HR> <UL> <LI>%N. <a href="%U" target=_new>%T</A> <small> <font color=red>%S</font> [Relevancy: %R]</small> <UL> <LI>%E <LI>%D <LI>%C <LI><a href="%U" target=_new>%u</A> </UL> </UL> ::HTMLNOTFOUND <P><font color=red>%Q not found</font> ::HTMLBOTTOM %B </BODY> </HTML> -- end of en.conf ---------------------------------------
Starting with version 1.3 we introduced an option of searching through one or several files. Each file is assigned an order number at the indexing stage, starting with '0'. For example:
[job localhost] [Index] URL http://www.mysite.com/ Statistic Append CharSet ByHTTPHeader MaxFiles 10000 StopWordsFile stopwords.txt Exclude search/,mail/,.zip,.gif,.jpg [Index] URL http://www.second.com/ Statistic Append CharSet ByHTTPHeader [Index] URL http://www.test.com/ Statistic Append CharSet ByHTTPHeader
Numbers of sites will be assigned as follows:
0 - http://www.mysite.com/ 1 - http://www.second.com/ 2 - http://www.test.com/
If you decide to perform re-indexing with the help of the configuration file:
[job addon] [Index] URL http://www.newsite.com/ Statistic Append CharSet ByHTTPHeader MaxFiles 10000 StopWordsFile stopwords.txt Exclude search/,mail/,.zip,.gif,.jpg
then the site http://www.newsite.com/ will be assigned number "0", or:
0 - http://www.mysite.com/ 0 - http://www.newsite.com/ 1 - http://www.second.com/ 2 - http://www.test.com/
It is necessary to use "d" parameter to perform a search at several sites. If the parameter is not set (default), the search is performed at all sites.
-- cnsearch.conf ---------------------------------------- ::CONFIG regcode = Enter Your registration code here ::CONFIG stats = password ::HTMLTOP <HTML> <HEAD> <TITLE>Search results - %Q</TITLE> </HEAD> <BODY> <table width=400 height=40 align=center bgcolor=#C0C0C0> <form action="%F" method=get><tr><td align=center> <input type=text name=q size=40 maxlength=64 value="%Q"> <input type=submit value="Search"> <br> <select name=d> <option value="0">www.mysite.com, www.newsite.com <option value="1">www.second.com <option value="2">www.test.com </select> </td></form></tr></table> Documents found: %O <B>%O</B><font color=gray>%W<B>%P</B></font><br> <br> <div align=right> Sort by: <a href="%A">date</a> | <a href="%L">relevancy</a> </div> ::HTMLRESULT <HR> <UL> <LI>%N. <a href="%U" target=_new>%T</A> <small> <font color=red>%S</font> [Relevancy: %R]</small> <UL> <LI>%E <LI>%D <LI>%C <LI><a href="%U" target=_new>%u</A> </UL> </UL> ::HTMLNOTFOUND <P><font color=red>%Q not found</font> ::HTMLBOTTOM %B </BODY> </HTML> -- end cnsearch.conf ------------------------------------
All options available through the Frontend configuration file are listed in this section.
This option sets path to the search index. It can be used if you do not want to store the search index in 'cgi-bin' directory or if you plan to use several search indexes.
Example:
::CONFIG path=/home/www/search/en/
for MS Windows
::CONFIG path=d:\wwwwww\search\en\
This option defines Content-type field of the header. Default value is "text/html". Search results can be returned in XML-file.
Example:
::CONFIG content-type = text/xml
Sets up search logic:
"And" logics is the fastest and we recommend using it if the search index size exeeds 100Mb.
We recommend using "Combined" logics at small sites with the total of less than 50 pages.
Example:
::CONFIG SearchType = Combined
Sets password to access statistics. See section "Statistics" about collecting and analysing stats.
Example:
::CONFIG stats = secret
Sets product registration code. See section "Registration" for more details.
Example:
::CONFIG regcode = JF7KF-KFJEP-4KSFT-K49GN-FJ40F
Sets the word, which will be displayed when special symbol %P is used.
Example:
::CONFIG StopWords =, Ignored Words :
Sets the word, which will be displayed whe the special symbol %S is used. Used only with "Combined" search logics.
Пример:
::CONFIG NonStrictMatch = [non strict match]
Two system parameters can be optimised - search speed and search index size.
It is necessary to optimise search speed if the search process is started frequently or target documents are displayed slowly.
Optimisation of the search index size becomes necessary in case of the disk space limit set by your hosting provider.
To optimise the search speed do the following:
1. Use defragmented index. In the defragmented index all results are stored in order and the data can be read very quickly.
Search index can be defragged with the help of "idefrag(.exe)" utility, which is stored in the indexer directory. It should be copied to the directory where the search index is stored (files index.cns, docs.cns, and files.cns) and executed. After defragmentatio file docs.cns will be replaced by results.cns. This file should not be modified!.
2. Use stop-words.
See details in section "Stop-Words"
3. Use "And" search logics.
When "And" logics is used disk access is reduced, which helps to increase the search speed greatly (it is valid fo defragmented search index only). See details here.
4. Switch Off Morphology Support
The search process is performed faster if the morphological dictionary lang.cns is used.
1. Use abridged search index.
Creation of file "fulltxt.cns" may be prohibited which helps to decrease search index size by 1.5 - 2 times. It can be done by using option Type in the Indexer configuration file.
2. Switch off morphology support
You may avoid use the morphological dictionary lang.cns, it may be 20Mb large.
3. Use stop-words.
See more details in section "stop-words"