|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.opencms.search.CmsSearch
public class CmsSearch
Helper class to access the search facility within a jsp.
Typically, the following fields are available for searching:
| Field Summary | |
|---|---|
protected boolean |
m_calculateCategories
Indicates if a category count should be calculated for the result list. |
protected String[] |
m_categories
Contains the list of categories that the search is limited to. |
protected Map |
m_categoriesFound
The result categories of a search. |
protected CmsObject |
m_cms
The cms object. |
protected int |
m_displayPages
The number of displayed pages returned by getPageLinks(). |
protected String[] |
m_fields
The list of fields to search. |
protected CmsSearchIndex |
m_index
The index to search. |
protected String |
m_indexName
The name of the search index. |
protected Exception |
m_lastException
The latest exception. |
protected int |
m_matchesPerPage
The number of matches per page. |
protected String |
m_nextUrl
The URL which leads to the next result page. |
protected int |
m_page
The current result page. |
protected int |
m_pageCount
The number of pages for the result list. |
protected CmsSearchParameters |
m_parameterRestriction
The restriction for the search parameters, used for "search in seach result". |
protected CmsSearchParameters |
m_parameters
The search parameters used for searching, build out of the given individual parameter values. |
protected String |
m_prevUrl
The URL which leads to the previous result page. |
protected String |
m_query
The current query. |
protected int |
m_queryLength
The minimum length of the search query. |
protected List |
m_result
The current search result. |
protected String |
m_searchParameters
The search parameter String. |
protected int |
m_searchResultCount
The total number of search results matching the query. |
protected String[] |
m_searchRoots
Contains the list of search root paths. |
protected Sort |
m_sortOrder
The search sort order. |
static Sort |
SORT_DATE_CREATED
Sort result documents by date of last modification, then score. |
static Sort |
SORT_DATE_LASTMODIFIED
Sort result documents by date of last modification, then score. |
static Sort |
SORT_DEFAULT
Default sort order (by document score - for this null gave best performance). |
static Sort |
SORT_TITLE
Sort result documents by title, then score. |
| Constructor Summary | |
|---|---|
CmsSearch()
Default constructor, used to instanciate the search facility as a bean. |
|
| Method Summary | |
|---|---|
boolean |
getCalculateCategories()
Returns true if a category overview should be shown as part of the result. |
String[] |
getCategories()
Returns the search categories. |
int |
getDisplayPages()
Returns the maximum number of pages which should be shown. |
String |
getFields()
Gets the current fields list. |
String |
getIndex()
Gets the name of the current search index. |
Exception |
getLastException()
Gets the last exception after a search operation. |
int |
getMatchesPerPage()
Gets the number of matches displayed on each page. |
String |
getNextUrl()
Gets the URL for the link to the next result page. |
int |
getPage()
Gets the current result page. |
Map |
getPageLinks()
Creates a sorted map of URLs to link to other search result pages. |
CmsSearchParameters |
getParameters()
Returns the search parameters used for searching, build out of the given individual parameter values. |
String |
getPreviousUrl()
Gets the URL for the link to the previous result page. |
String |
getQuery()
Gets the current search query. |
int |
getQueryLength()
Gets the minimum search query length. |
String |
getSearchParameters()
Creates a String with the necessary search parameters for page links. |
List |
getSearchResult()
Returns the search result for the current query, as a list of objects. |
Map |
getSearchResultCategories()
Returns a map of categories (Strings) for the last search result, mapped to the hit count (Integer) of the documents in this category, or null if the categories have not been calculated. |
int |
getSearchResultCount()
Returns the total number of search results matching the query. |
String[] |
getSearchRoots()
Returns the search roots. |
Sort |
getSortOrder()
Returns the sort order used for sorting the results of s search. |
void |
init(CmsObject cms)
Initializes the bean with the cms object. |
void |
setCalculateCategories(boolean calculateCategories)
Sets the flag that controls calculation of result categories for the next search, use this only if it's really required since the search can become very slow using this option. |
void |
setCategories(String[] categories)
Sets the search categories, all search results must be in one of the categories, the category set must match the indexed category exactly. |
void |
setDisplayPages(int value)
Sets the maximum number of pages which should be shown. |
void |
setField(String[] fields)
Sets the fields to search. |
void |
setIndex(String indexName)
Set the name of the index to search. |
void |
setMatchesPerPage(int matches)
Sets the number of matches per page. |
void |
setPage(int page)
Sets the current result page. |
void |
setQuery(String query)
Sets the search query. |
void |
setQueryLength(int length)
Sets the minimum length of the search query. |
void |
setResultRestriction(CmsSearchParameters restriction)
Restrict the result of the next search to the results of the last search, restricted with the provided parameters. |
void |
setSearchRoot(String searchRoot)
Convenience method to set exactly one search root. |
void |
setSearchRoots(String[] searchRoots)
Sets the search root list. |
void |
setSortOrder(Sort sortOrder)
Sets the sort order used for sorting the results of s search. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final Sort SORT_DATE_CREATED
public static final Sort SORT_DATE_LASTMODIFIED
public static final Sort SORT_DEFAULT
null gave best performance).
public static final Sort SORT_TITLE
protected boolean m_calculateCategories
protected String[] m_categories
protected Map m_categoriesFound
protected transient CmsObject m_cms
protected int m_displayPages
protected String[] m_fields
protected CmsSearchIndex m_index
protected String m_indexName
protected Exception m_lastException
protected int m_matchesPerPage
protected String m_nextUrl
protected int m_page
protected int m_pageCount
protected CmsSearchParameters m_parameterRestriction
protected CmsSearchParameters m_parameters
protected String m_prevUrl
protected String m_query
protected int m_queryLength
protected List m_result
protected String m_searchParameters
protected int m_searchResultCount
protected String[] m_searchRoots
protected Sort m_sortOrder
| Constructor Detail |
|---|
public CmsSearch()
| Method Detail |
|---|
public boolean getCalculateCategories()
true if a category overview should be shown as part of the result.Please note: The calculation of the category count slows down the search time by an order of magnitude. Make sure that you only use this feature if it's really required! Be especially careful if your search result list can become large (> 1000 documents), since in this case overall system performance will certainly be impacted considerably when calculating the categories.
true if a category overview should be shown as part of the resultpublic String[] getCategories()
public int getDisplayPages()
public String getFields()
public String getIndex()
public Exception getLastException()
public int getMatchesPerPage()
public String getNextUrl()
public int getPage()
public Map getPageLinks()
The key values are Integers representing the page number, the entry holds the corresponding link.
public CmsSearchParameters getParameters()
public String getPreviousUrl()
public String getQuery()
public int getQueryLength()
public String getSearchParameters()
public List getSearchResult()
CmsSearchResult objects.
public Map getSearchResultCategories()
null if the categories have not been calculated.
getCalculateCategories(),
setCalculateCategories(boolean)public int getSearchResultCount()
public String[] getSearchRoots()
Only resources that are sub-resources of one of the search roots are included in the search result.
The search roots are used in addition to the current site root of the user performing the search.
By default, the search roots contain only one entry with an empty string.
public Sort getSortOrder()
public void init(CmsObject cms)
cms - the cms objectpublic void setCalculateCategories(boolean calculateCategories)
Please note: The calculation of the category count slows down the search time by an order of magnitude. Make sure that you only use this feature if it's really required! Be especially careful if your search result list can become large (> 1000 documents), since in this case overall system performance will certainly be impacted considerably when calculating the categories.
calculateCategories - if true, the category count will be calculated for the next searchpublic void setCategories(String[] categories)
All categories will automatically be trimmed and lowercased, since search categories are also stored this way in the index.
categories - the categories to setpublic void setDisplayPages(int value)
Enter an odd value to achieve a nice, "symmetric" output.
value - the maximum number of pages which should be shownpublic void setField(String[] fields)
If the fields are set to null,
or not set at all, the default fields "content" and "meta" are used.
For a list of valid field names, see the Interface constants of
.
I_CmsDocumentFactory
fields - the fields to searchpublic void setIndex(String indexName)
A former search result will be deleted.
indexName - the name of the indexpublic void setMatchesPerPage(int matches)
matches - the number of matches per pagepublic void setPage(int page)
page - the current result pagepublic void setQuery(String query)
The syntax of the query depends on the search engine used. A former search result will be deleted.
query - the search query (escaped format)public void setQueryLength(int length)
length - the minimum search query lengthpublic void setResultRestriction(CmsSearchParameters restriction)
Use this for "seach in search result" functions.
restriction - the restriction to useCmsSearchParameters.restrict(CmsSearchParameters)public void setSearchRoot(String searchRoot)
searchRoot - the search root to setsetSearchRoots(String[])public void setSearchRoots(String[] searchRoots)
Only resources that are sub-resources of one of the search roots are included in the search result.
The search roots set here are used in addition to the current site root of the user performing the search.
By default, the search roots contain only one entry with an empty string.
searchRoots - the search roots to setpublic void setSortOrder(Sort sortOrder)
sortOrder - the sort order to set
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||