The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Apache::Wyrd::Site::SearchResults - Perform a word-search of Pages

SYNOPSIS

  <BASENAME::SearchResults max="20">
    <BASENAME::Template name="list"><table>$:items</table></BASENAME::Template>
    <BASENAME::Template name="item">
      <tr><td><a href="$:name">$:title</a>?:published{, posted: $:published}
      ?:description{<BR>&#151;$:description}</td></tr>
    </BASENAME::Template>
    <BASENAME::Template name="instructions>
      ...instructions here...
    </BASENAME::Template>
    <BASENAME::Template name="failed>
      The search for 
        <BASENAME::CGISetter>
          "$:searchstring"
        </BASENAME::CGISetter>did not produce any results.
    </BASENAME::Template>
  </BASENAME::SearchResults>

DESCRIPTION

SearchResults is another form of Apache::Wyrd::Site::Pull, which uses the contents of the CGI variable "searchstring" to produce a list of search results from an Apache::Wyrd::Site::Index object. The searchstring variable can use any combination of parens, quotes, logical terms and +/- elements to limit the wordsearch to a smaller set. This Pull processes the list of hashrefs of document metadata returned by the index object.

The SearchResults object also adds to each result item the key-value pairs:

rank

Meaning the rank (1 = best) of the document as to relevance within the search set.

counter

The ordinal number of the item in the found set.

weighted_rank

Meaning the relative rank of the document in comparison with the others of the found set (in percent, 100=best).

relevance

The generic, unweighted relevance score, based on a function of word-incidents to document size (wordcount).

To allow the individual items of the "search results" block to be related to each other. Additionally, if a previous search result is given in the CGI variable "previous" and the CGI variable "within" is a non-null value (as would be returned by a hidden INPUT tag named "previous" and a checkbox named "within", The searcstring will be limited to the previous results.

Additionally, the CGI variable "max" is used to limit the search results to "max" number of items or less, and the "next" and "beginning" CGI variables are used to define a window of "max" number of of search results within a search set, which is to say that as the frame moves to the window defined by "next", the Apache::Wyrd::Intefaces::Setter elements will set $:next in the list template to the current value of the CGI variable "next" + the value of "max". This allows the webmaster to easily construct a moving-window search result.

HTML ATTRIBUTES

decimals

How many digits after the decimal point to include in weighted results.

sort

Which attributes of the sorted objects should be used to sort the list. Note that if a sort item begins with "rev_", the sort is performed in reverse.

instructions

What to provide in case no searchstring parameter was given.

failed

What to provide in case of a failed search. Often suppled as an Apache::Wyrd::Template Wyrd.

list/item

As with Apache::Wyrd::Site::Pull, the templates (also often supplied as Apache::Wyrd::Template Wyrds, which provide formatting to the list itself and to the items of the list.

FLAGS

reverse

Sort in reverse.

weighted

Sort by weighted relevance rather than generic score.

PERL METHODS

(format: (returns) name (arguments after self))

(void) _set_defaults (void)

method description

(array) _doc_filter (array)

A "hook" method for filtering each (hashref-ed) search result. The search results are given as an array of hashrefs, and similar array is expected.

BUGS/CAVEATS

Reserves the _format_output method.

AUTHOR

Barry King <wyrd@nospam.wyrdwright.com>

SEE ALSO

Apache::Wyrd

General-purpose HTML-embeddable perl object

Apache::Wyrd::Services::Index
Apache::Wyrd::Services::MySQLIndex
Apache::Wyrd::Site::Index
Apache::Wyrd::Site::MySQLIndex

Various index objects for site organization.

Apache::Wyrd::Interfaces::IndexUser

Convenience class for Wyrds which interface with Indexes

Apache::Wyrd::Site::Pull

Abstract class for lists of pages

LICENSE

Copyright 2002-2007 Wyrdwright, Inc. and licensed under the GNU GPL.

See LICENSE under the documentation for Apache::Wyrd.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 180:

You forgot a '=back' before '=head1'