JavaScript
Search Engine

Site Map

Home
Example Site
Simplified
Advanced
Create Index
Using Wizard
Editing Code
search.html
Configuration
Search This Site
Conditions of Use
Contact
E-mail

 

Click here for important news about the JavaScript Search Engine

Configuring the JavaScript Search Engine

It is possible to change the format of the output the JavaScript Search Engine produces.  This is done by altering some values below your page indexes.

If you view the source of the search.html file you will see this:

var ShowDetailedOutput = true
      
var ShowQuoteCount = true
      
var SortResults = true
      
var SortOrderTitle = 1
var SortOrderDescription = 2
var SortOrderURL = 3
var SortOrderContent = 4

Show Detailed Output

This can be set to true or false.  If it is true then a quote is displayed of every occurrence of the search word in the body text.  If the word is found in the title, description or URL then no quotes are displayed.

ShowDetailedOutput = true

       1. Her Voice
    URL  http://www.javascript.freeuk.com/example/hervoice.html
    Classic poetry online. Her Voice by Oscar Wilde
        ".. In his wandering; Sit closer love: it was here I trow I .."
        ".. those times are over and done, Love's web is spun. Look .."
        ".. nothing left to say But this, that love is never lost, Keen .."

ShowDetailedOutput = false

      1. Her Voice
    URL  http://www.javascript.freeuk.com/example/hervoice.html
    Classic poetry online. Her Voice by Oscar Wilde
        ".. In his wandering; Sit closer love: it was here I trow I .."

Show Quote Count

This can be set to true or false.  If it is true then the number of times the search word has been quoted in the content is displayed.  If the word is found in the title, description or URL then no quotes are displayed.

ShowQuoteCount = true

       1. There's a certain slant of light
    URL  http://www.javascript.freeuk.com/example/certainslant.html
    Classic poetry online. There's a certain slant of light by Emily Dickinson
        ".. affliction Sent us of the air. When it comes, the landscape .."
        ".. listens, Shadows hold their breath; When it goes, 't is like the .."
        (2 quotes)

2. The Land of Dreams
    URL  http://www.javascript.freeuk.com/example/landofdreams.html
    Classic poetry online. The Land of Dreams by William Blake
        ".. joy, like a dove I mourn; O! when shall I again return?" .."
        (1 quote)

ShowQuoteCount = false

      1. There's a certain slant of light
    URL  http://www.javascript.freeuk.com/example/certainslant.html
    Classic poetry online. There's a certain slant of light by Emily Dickinson
        ".. affliction Sent us of the air. When it comes, the landscape .."
        ".. listens, Shadows hold their breath; When it goes, 't is like the .."

2. The Land of Dreams
    URL  http://www.javascript.freeuk.com/example/landofdreams.html
    Classic poetry online. The Land of Dreams by William Blake
        ".. joy, like a dove I mourn; O! when shall I again return?" .."

Sort Results

This can be true or false.  It is normally desirable to sort the matched pages into order of relevance.  The default is to list the pages at the top where the search word was found in the title, description or URL, followed by the pages where the word was found in the body text (content).

You can override this by setting this value to false.  The pages will be listed in the order they appear in the indexes.  By doing this you can place what you think the most important pages are at the top of the returned results.

Sort Order

If you have set Sort Results to true then the order of matched pages is taken from these four variables.

By changing these you can modify what you feel should be placed at the top of the results page.

The default order is to list in order of title, description and URL, followed by the pages where the word was found in the body text (content).

This can be seen from the default values of

var SortOrderTitle = 1
var SortOrderDescription = 2
var SortOrderURL = 3
var SortOrderContent = 4

To change the sort order you must alter the numbers.  There must always be four numbers 1, 2, 3 and 4.  Change the variable of the number you want to have most important to 1, the next important to 2 etc.

If I wanted to change to sort order so that pages where the word is only in the content are listed first, then URL matches, then title matches and finally description matches, then the code would be as follows:

var SortOrderTitle = 3
var SortOrderDescription = 4
var SortOrderURL = 2
var SortOrderContent = 1


See the Advanced Example for a demonstration of alternative sort orders.