|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.avalon.framework.logger.AbstractLogEnabled org.apache.cocoon.xml.AbstractXMLProducer org.apache.cocoon.generation.AbstractGenerator org.apache.cocoon.generation.ServiceableGenerator org.apache.cocoon.generation.SearchGenerator
public class SearchGenerator
Generates an XML representation of a search result.
This generator generates xml content representening an XML search. The generated xml content contains the search result, the search query information, and navigation information about the search results. The query is sent to the generator, either via the 'queryString' request parameter or the 'query' SiteMap parameter. The sitemap overides the request.
Search xml sample generated by this generator:
<?xml version="1.0" encoding="UTF-8"?> <search:results date="1008437081064" query-string="cocoon" start-index="0" page-length="10" xmlns:search="http://apache.org/cocoon/search/1.0" xmlns:xlink="http://www.w3.org/1999/xlink"> <search:hits total-count="125" count-of-pages="13"> <search:hit rank="0" score="1.0" uri="http://localhost:8080/cocoon/documents/hosting.html"> <search:field name="title">Document Title<search:field/> <search:hit/> ... </search:hits> <search:navigation total-count="125" count-of-pages="13" has-next="true" has-previous="false" next-index="10" previous-index="0"> <search:navigation-page start-index="0"/> <search:navigation-page start-index="10"/> ... <search:navigation-page start-index="120"/> </search:navigation> </search:results>
Field Summary | |
---|---|
protected static String |
ANALYZER_PARAM
Setup parameter name of analyzer name, ie analyzer . |
protected static String |
ANALYZER_PARAM_DEFAULT
Default value of analyzer parameter analyzer , ie org.apache.lucene.analysis.standard.StandardAnalyzer . |
protected static String |
CDATA
Description of the Field |
protected static String |
COUNT_OF_PAGES_ATTRIBUTE
Attribute count-of-pages of hits element. |
protected static String |
DATE_ATTRIBUTE
Attribute date of results element. |
protected static String |
FIELD_ELEMENT
Child element field of the hit element. |
protected static String |
HAS_NEXT_ATTRIBUTE
Attribute has-next of navigation-page element. |
protected static String |
HAS_PREVIOUS_ATTRIBUTE
Attribute has-next of navigation-page element. |
protected static String |
HIT_ELEMENT
Child element of generated xml content, ie hit . |
protected static String |
HITS_ELEMENT
Child element of generated xml content, ie hits . |
protected static String |
INDEX_PARAM
Setup parameter name of index directory, ie index . |
protected static String |
INDEX_PARAM_DEFAULT
Default value of setup parameter index , ie index . |
protected static String |
NAME_ATTRIBUTE
Attribute name of hit element. |
protected static String |
NAMESPACE
The XML namespace for the output document. |
protected static String |
NAVIGATION_ELEMENT
Child element of generated xml content, ie navigation . |
protected static String |
NAVIGATION_PAGE_ELEMENT
Child element of generated xml content, ie navigation-page . |
protected static String |
NEXT_INDEX_ATTRIBUTE
Attribute next-index of navigation-page element. |
protected static String |
PAGE_LENGTH_ATTRIBUTE
Attribute page-length of results element. |
protected static int |
PAGE_LENGTH_DEFAULT
|
protected static String |
PAGE_LENGTH_PARAM
Setup parameter name specifying the name of page-length query parameter, ie page-length . |
protected static String |
PAGE_LENGTH_PARAM_DEFAULT
|
protected static String |
PREFIX
The XML namespace prefix for the output document. |
protected static String |
PREVIOUS_INDEX_ATTRIBUTE
Attribute previous-index of navigation-page element. |
protected static String |
Q_FIELD_ELEMENT
QName of child element search:field of the hit element. |
protected static String |
Q_HIT_ELEMENT
QName of child element of generated xml content, ie search:hit . |
protected static String |
Q_HITS_ELEMENT
QName of child element of generated xml content, ie search:hits . |
protected static String |
Q_NAVIGATION_ELEMENT
QName of child element of generated xml content, ie search:navigation . |
protected static String |
Q_NAVIGATION_PAGE_ELEMENT
QName of child element of generated xml content, ie search:navigation-page . |
protected static String |
Q_RESULTS_ELEMENT
Qualified name of root element of generated xml content, ie search:results . |
protected static String |
QUERY_PARAM
Setup the actual query from generator parameter, ie query . |
protected static String |
QUERY_STRING_ATTRIBUTE
Attribute query-string of results element. |
protected static String |
QUERY_STRING_PARAM
Setup parameter name specifying the name of query-string query parameter, ie query-string . |
protected static String |
QUERY_STRING_PARAM_DEFAULT
Default value of setup parameter query-string , ie queryString . |
protected static String |
RANK_ATTRIBUTE
Attribute rank of hit element. |
protected static String |
RESULTS_ELEMENT
Name of root element of generated xml content, ie results . |
protected static String |
SCORE_ATTRIBUTE
Attribute score of hit element. |
protected static String |
START_INDEX_ATTRIBUTE
Attribute start-index of results element. |
protected static int |
START_INDEX_DEFAULT
|
protected static String |
START_INDEX_NEXT_PARAM
Setup parameter name specifying the name of start-next-index query parameter, ie start-next-index . |
protected static String |
START_INDEX_NEXT_PARAM_DEFAULT
Default value of setup parameter start-next-index , ie startNextIndex . |
protected static String |
START_INDEX_PARAM
Setup parameter name specifying the name of start-index query parameter, ie start-index . |
protected static String |
START_INDEX_PARAM_DEFAULT
Default value of setup parameter start-index , ie startIndex . |
protected static String |
START_INDEX_PREVIOUS_PARAM
Setup parameter name specifying the name of start-previous-index query parameter, ie start-previous-index . |
protected static String |
START_INDEX_PREVIOUS_PARAM_DEFAULT
Default value of setup parameter start-previous-index , ie startPreviousIndex . |
protected static String |
TOTAL_COUNT_ATTRIBUTE
Attribute total-count of hits element. |
protected static String |
URI_ATTRIBUTE
Attribute uri of hit element. |
protected static String |
XLINK_NAMESPACE
The XML namespace for xlink |
Fields inherited from class org.apache.cocoon.generation.ServiceableGenerator |
---|
manager |
Fields inherited from class org.apache.cocoon.generation.AbstractGenerator |
---|
objectModel, parameters, resolver, source |
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer |
---|
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer |
Fields inherited from interface org.apache.cocoon.generation.Generator |
---|
ROLE |
Constructor Summary | |
---|---|
SearchGenerator()
|
Method Summary | |
---|---|
void |
contextualize(Context context)
Contextualize this class. |
void |
generate()
Generate xml content describing search results. |
void |
recycle()
Recycle the generator |
void |
setup(SourceResolver resolver,
Map objectModel,
String src,
Parameters par)
setup all members of this generator. |
Methods inherited from class org.apache.cocoon.generation.ServiceableGenerator |
---|
dispose, service |
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer |
---|
setConsumer, setContentHandler, setLexicalHandler |
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled |
---|
enableLogging, getLogger, setupLogger, setupLogger, setupLogger |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.cocoon.xml.XMLProducer |
---|
setConsumer |
Field Detail |
---|
protected static final String NAMESPACE
protected static final String PREFIX
protected static final String XLINK_NAMESPACE
protected static final String CDATA
protected static final String RESULTS_ELEMENT
results
.
protected static final String Q_RESULTS_ELEMENT
search:results
.
protected static final String DATE_ATTRIBUTE
date
of results
element.
It contains the date a long value, indicating when a search
generated this xml content.
protected static final String QUERY_STRING_ATTRIBUTE
query-string
of results
element.
Echos the queryString
query parameter.
protected static final String START_INDEX_ATTRIBUTE
start-index
of results
element.
Echoes the startIndex
query parameter.
protected static final String PAGE_LENGTH_ATTRIBUTE
page-length
of results
element.
Echoes the pageLenth
query parameter.
protected static final String NAME_ATTRIBUTE
name
of hit
element.
protected static final String HITS_ELEMENT
hits
.
This element describes all hits.
protected static final String Q_HITS_ELEMENT
search:hits
.
This element describes all hits.
protected static final String TOTAL_COUNT_ATTRIBUTE
total-count
of hits
element.
The value describes total number of hits found by the search engine.
protected static final String COUNT_OF_PAGES_ATTRIBUTE
count-of-pages
of hits
element.
The value describes number of pages needed for all hits.
protected static final String HIT_ELEMENT
hit
.
This element describes a single hit.
protected static final String Q_HIT_ELEMENT
search:hit
.
This element describes a single hit.
protected static final String RANK_ATTRIBUTE
rank
of hit
element.
The value describes the count index of this hits, ranging between 0, and
total-count minus 1.
protected static final String SCORE_ATTRIBUTE
score
of hit
element.
The value describes the score of this hits, ranging between 0, and 1.0.
protected static final String URI_ATTRIBUTE
uri
of hit
element.
The value describes the uri of a document matching the search query.
protected static final String FIELD_ELEMENT
field
of the hit
element.
This element contains value of the stored field of a hit.
protected static final String Q_FIELD_ELEMENT
search:field
of the hit
element.
protected static final String NAVIGATION_ELEMENT
navigation
.
This element describes some hints for easier navigation.
protected static final String Q_NAVIGATION_ELEMENT
search:navigation
.
protected static final String NAVIGATION_PAGE_ELEMENT
navigation-page
.
This element describes the start-index of page containing hits.
protected static final String Q_NAVIGATION_PAGE_ELEMENT
search:navigation-page
.
This element describes the start-index of page containing hits.
protected static final String HAS_NEXT_ATTRIBUTE
has-next
of navigation-page
element.
The value is true if a next navigation control should be presented.
protected static final String HAS_PREVIOUS_ATTRIBUTE
has-next
of navigation-page
element.
The value is true if a previous navigation control should be presented.
protected static final String NEXT_INDEX_ATTRIBUTE
next-index
of navigation-page
element.
The value describes the start-index of the next-to-be-presented page.
protected static final String PREVIOUS_INDEX_ATTRIBUTE
previous-index
of navigation-page
element.
The value describes the start-index of the previous-to-be-presented page.
protected static final String INDEX_PARAM
index
.
protected static final String INDEX_PARAM_DEFAULT
index
, ie index
.
protected static final String ANALYZER_PARAM
analyzer
.
protected static final String ANALYZER_PARAM_DEFAULT
analyzer
, ie org.apache.lucene.analysis.standard.StandardAnalyzer
.
protected static final String QUERY_PARAM
query
.
protected static final String QUERY_STRING_PARAM
query-string
.
protected static final String QUERY_STRING_PARAM_DEFAULT
query-string
, ie queryString
.
protected static final String START_INDEX_PARAM
start-index
.
protected static final String START_INDEX_PARAM_DEFAULT
start-index
, ie startIndex
.
protected static final String START_INDEX_NEXT_PARAM
start-next-index
.
protected static final String START_INDEX_NEXT_PARAM_DEFAULT
start-next-index
, ie startNextIndex
.
protected static final String START_INDEX_PREVIOUS_PARAM
start-previous-index
.
protected static final String START_INDEX_PREVIOUS_PARAM_DEFAULT
start-previous-index
, ie startPreviousIndex
.
protected static final int START_INDEX_DEFAULT
protected static final String PAGE_LENGTH_PARAM
page-length
.
protected static final String PAGE_LENGTH_PARAM_DEFAULT
protected static final int PAGE_LENGTH_DEFAULT
Constructor Detail |
---|
public SearchGenerator()
Method Detail |
---|
public void contextualize(Context context) throws ContextException
Especially retrieve the work directory. If the index directory is specified relativly, the working directory is used as home directory of the index directory.
contextualize
in interface Contextualizable
context
- Context to use
ContextException
- If contextualizing fails.public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) throws ProcessingException, SAXException, IOException
setup
in interface SitemapModelComponent
setup
in class AbstractGenerator
ProcessingException
SAXException
IOException
public void generate() throws IOException, SAXException, ProcessingException
generate
in interface Generator
IOException
- when there is a problem reading the from file system.
SAXException
- when there is a problem creating the output SAX events.
ProcessingException
- when there is a problem obtaining the hitspublic void recycle()
recycle
in interface Recyclable
recycle
in class AbstractGenerator
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |