SAP NetWeaver '04

com.sapportals.wcm.control.released.search
Class SearchQueryListBuilder

java.lang.Object
  |
  +--com.sapportals.wcm.control.released.search.SearchQueryListBuilder

public class SearchQueryListBuilder
extends java.lang.Object

The SearchQueryListBuilder provides auxiliary functions for building a search query list for the KM index management API

Copyright 2004 SAP AG


Constructor Summary
SearchQueryListBuilder()
          Constructor of SearchQueryListBuilder
SearchQueryListBuilder(java.util.Hashtable searchParameters)
          Constructor method of SearchQueryListBuilder for which the search parameters must be provided initially.
 
Method Summary
 IQueryEntryList buildDidYouMeanQueryEntries(IQueryEntryList oldQuery, java.lang.String oldTerm, java.lang.String didYouMeanTerm)
          Provides an adapted new query entry list for a "Did You Mean" search.
 IQueryEntry buildQueryEntryConnector(java.lang.String connector)
          Builds a single query entry that can be used as the connection between two query entry lists.
 IQueryEntry buildQueryEntryTimeWindow(IPropertyName propertyName, java.util.Date startDate, java.util.Date endDate)
          Simple method for building a time window query entry list.
 IQueryEntryList buildSearchQueryList()
          Central method for building query entry list that takes all set conditions into account.
static byte getBestSearchAction(java.lang.String text)
          Algorithmus that returns the 'best practice' search method.
static java.lang.String getDidYouMeanTerm(IQueryEntryList queryEntryList, java.lang.String oldSearchTerm)
          Method extracts the "Did you mean" search term.
 java.lang.String getSearchAddProps()
          Returns the current additional search properties.
 java.lang.String getSearchTerm()
          Returns the current SearchTerm that will be recognized when building the query entry list.
 java.lang.String getSelectedCustomProps()
          Returns the current property and value setting for the custom property query condition.
 java.lang.String getSelectedDescription()
          Returns the current setting for the description condition of a document.
 java.util.Date getSelectedEndDate()
          Returns the current SelectedEndDate attribute that will be recognized when building the query entry list.
 java.lang.String getSelectedItems()
          Returns the current SelectedItems attribute that will be recognized when building the query entry list.
 java.lang.String getSelectedNotOlderRange()
          Returns the current setting for the document time range.
 java.lang.String getSelectedSearchAction()
          Returns the current search method for the textual search on content, description, and display name for the specified search term.
 java.lang.String getSelectedSimilarTerms()
          Returns the current setting for the similar terms condition.
 java.util.Date getSelectedStartDate()
          Returns the current SelectedStartDate attribute that will be recognized when building the query entry list.
 java.lang.String getSelectedTitle()
          Returns the current search setting for the selected display name/title of a document.
 java.lang.String getTermConnection()
          Returns the current setting for term connection mode.
 boolean isDescriptionIncluded()
          Returns the current setting for the description included flag.
 boolean isDisplaynameIncluded()
          Returns the current setting for the display name included flag.
 void setDescriptionIncluded(boolean value)
          Sets flag for search on description during normal term search.
 void setDisplaynameIncluded(boolean value)
          Sets flag for search on display name during normal term search.
 void setSearchAddProps(java.lang.String value)
          Sets additional search properties.
 void setSearchParameters(java.util.Hashtable searchParameters)
          Sets the search parameters by means of a hash table.
 void setSearchTerm(java.lang.String searchTerm)
          Sets the SearchTerm attribute for the query entry list to be built.
 void setSelectedCustomProps(java.lang.String value)
          Sets a combination of property name and value that will be recognized as the custom property query condition.
 void setSelectedDescription(java.lang.String value)
          Sets the parameter that will be used to search within the description.
 void setSelectedEndDate(java.util.Date value)
          Sets the SelectedEndDate attribute that will be recognized as the end date when building the query entry list for the date properties 'Modified' (cm_modified) and 'Created'. (
 void setSelectedItems(java.lang.String value)
          Sets the item selection option that will be recognized when building the query entry list.
 void setSelectedNotOlderRange(java.lang.String value)
          Sets the document time range condition during which the document was last modified.
 void setSelectedSearchAction(java.lang.String value)
          Sets the search method for the textual search on content, description, and display name for the specified search term.
 void setSelectedSimilarTerms(java.lang.String value)
          Sets similar terms string.
 void setSelectedStartDate(java.util.Date value)
          Sets the SelectedStartDate attribute that will be recognized as the start date when building the query entry list for the date properties 'Modified' (cm_modified) and 'Created'. (
 void setSelectedTitle(java.lang.String value)
          Sets the parameter that will be used to search only within the display name.
 void setTermConnection(java.lang.String value)
          Sets mode for search terms query connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SearchQueryListBuilder

public SearchQueryListBuilder()
Constructor of SearchQueryListBuilder

SearchQueryListBuilder

public SearchQueryListBuilder(java.util.Hashtable searchParameters)
Constructor method of SearchQueryListBuilder for which the search parameters must be provided initially.
See method setSearchParameters for detailed information.
Parameters:
searchParameters - new SearchParameters table
See Also:
setSearchParameters(java.util.Hashtable), buildSearchQueryList()
Method Detail

setSearchTerm

public void setSearchTerm(java.lang.String searchTerm)
Sets the SearchTerm attribute for the query entry list to be built. This SearchTerm will be used for searching in the following properties:
- content of documents
- display name (if enabled via setDisplaynameIncluded)
- description (if enabled via setDescriptionIncluded)
- additionally defined attributes (if specified via setSearchAddProps)
Parameters:
searchTerm - new SearchTerm for the "standard" search request
See Also:
getSearchTerm(), setDisplaynameIncluded(boolean), setDescriptionIncluded(boolean), setSearchAddProps(java.lang.String), isDisplaynameIncluded(), isDescriptionIncluded(), getSearchAddProps()

getSearchTerm

public java.lang.String getSearchTerm()
Returns the current SearchTerm that will be recognized when building the query entry list.
Returns:
current SearchTerm
See 'set' method for detailed information.
See Also:
setSearchTerm(java.lang.String)

setSelectedItems

public void setSelectedItems(java.lang.String value)
Sets the item selection option that will be recognized when building the query entry list.
All documents - SearchParamConst.ITEM_ALL
Only Folders - SearchParamConst.ITEM_ONLY_FOLDERS
Only Docs - SearchParamConst.ITEM_ONLY_DOCS
No Folders - SearchParamConst.ITEM_NO_FOLDERS
Further categories may be added in the future.
Parameters:
value - new SelectedItems attribute
See Also:
getSelectedItems()

getSelectedItems

public java.lang.String getSelectedItems()
Returns the current SelectedItems attribute that will be recognized when building the query entry list.
See 'set' method for detailed information.
Returns:
current SelectedItems attribute
See Also:
setSelectedItems(java.lang.String)

setSelectedStartDate

public void setSelectedStartDate(java.util.Date value)
Sets the SelectedStartDate attribute that will be recognized as the start date when building the query entry list for the date properties 'Modified' (cm_modified) and 'Created'. (cm_created) connected by OR.
The attributes SelectedStartDate and SelectedEndDate both need to be set.
For different properties, use the method buildQueryEntryTimeWindow directly.
Parameters:
value - new SelectedStartDate attribute
See Also:
getSelectedStartDate(), setSelectedEndDate(java.util.Date), getSelectedEndDate(), buildQueryEntryTimeWindow(com.sapportals.wcm.repository.IPropertyName, java.util.Date, java.util.Date)

getSelectedStartDate

public java.util.Date getSelectedStartDate()
Returns the current SelectedStartDate attribute that will be recognized when building the query entry list.
See 'set' method for detailed information.
Returns:
current SelectedStartDate attribute
See Also:
setSelectedStartDate(java.util.Date), setSelectedEndDate(java.util.Date), getSelectedEndDate(), buildQueryEntryTimeWindow(com.sapportals.wcm.repository.IPropertyName, java.util.Date, java.util.Date)

setSelectedEndDate

public void setSelectedEndDate(java.util.Date value)
Sets the SelectedEndDate attribute that will be recognized as the end date when building the query entry list for the date properties 'Modified' (cm_modified) and 'Created'. (cm_created) connected by OR. The attributes SelectedStartDate and SelectedEndDate both need to be set.
For different dates, as for properties use the method buildQueryEntryTimeWindow directly.
Parameters:
value - new SelectedStartDate attribute
See Also:
getSelectedEndDate(), setSelectedStartDate(java.util.Date), getSelectedStartDate(), buildQueryEntryTimeWindow(com.sapportals.wcm.repository.IPropertyName, java.util.Date, java.util.Date)

getSelectedEndDate

public java.util.Date getSelectedEndDate()
Returns the current SelectedEndDate attribute that will be recognized when building the query entry list.
See 'set' method for detailed information.
Returns:
current SelectedEndDate attribute
See Also:
setSelectedEndDate(java.util.Date), setSelectedStartDate(java.util.Date), getSelectedStartDate(), buildQueryEntryTimeWindow(com.sapportals.wcm.repository.IPropertyName, java.util.Date, java.util.Date)

setSelectedSearchAction

public void setSelectedSearchAction(java.lang.String value)
Sets the search method for the textual search on content, description, and display name for the specified search term.
Possible modes:
Fuzzy search logic - SearchParamConst.ACTION_FUZZY
Exact search - SearchParamConst.ACTION_EXACT
Linguistic search - SearchParamConst.ACTION_LINGUISTIC
Automatic decision - SearchParamConst.ACTION_AUTOMATIC
If no value is specified, the 'best practice' value is taken (corresponds to AUTOMATIC).
Parameters:
value - new SelectedSearchAction attribute
See Also:
getBestSearchAction(java.lang.String), getSelectedSearchAction(), setSearchTerm(java.lang.String)

getSelectedSearchAction

public java.lang.String getSelectedSearchAction()
Returns the current search method for the textual search on content, description, and display name for the specified search term.
See 'set' method for detailed information.
Returns:
current SelectedSearchAction attribute
See Also:
getBestSearchAction(java.lang.String), setSelectedSearchAction(java.lang.String), setSearchTerm(java.lang.String)

setSearchAddProps

public void setSearchAddProps(java.lang.String value)
Sets additional search properties. Within these properties the search term (see method setSearchTerm) will be searched for additionally. With standard, only content, description, and the display name are searched for. Specify multiple properties as a comma-separated list of unique property IDs.
Example: createdby,modifiedby,embedded-keywords
Be aware that this causes additional search time.
Parameters:
searchAddProps - - new SearchAddProps attribute
See Also:
getSearchAddProps(), setSearchTerm(java.lang.String)

getSearchAddProps

public java.lang.String getSearchAddProps()
Returns the current additional search properties.
See 'set' method for detailed information.
Returns:
current SearchAddProps attribute
See Also:
setSearchAddProps(java.lang.String), setSearchTerm(java.lang.String)

setSelectedCustomProps

public void setSelectedCustomProps(java.lang.String value)
Sets a combination of property name and value that will be recognized as the custom property query condition. Logical operators are supported for some property types. You can specify multiple properties.
Different properties are connected by AND.
Identical properties are connected by OR.
For supported operators, syntax, and options, refer to the current specification and documentation for the configuration of the search user interface (e.g. parameter 'Predefined Properties').
Parameters:
selectedCustomProps - new SelectedCustomProps attribute
See Also:
getSelectedCustomProps()

getSelectedCustomProps

public java.lang.String getSelectedCustomProps()
Returns the current property and value setting for the custom property query condition.
See 'set' method for detailed information.
Returns:
current SelectedCustomProps attribute
See Also:
setSelectedCustomProps(java.lang.String)

setSelectedNotOlderRange

public void setSelectedNotOlderRange(java.lang.String value)
Sets the document time range condition during which the document was last modified.
Possible values are:
No value - SearchParamConst.NOT_OLDER_NONE - no query entry is built
Changed within the today - SearchParamConst.NOT_OLDER_TODAY
Changed within the last week - SearchParamConst.NOT_OLDER_WEEK
Changed within the last month - SearchParamConst.NOT_OLDER_MONTH
Changed within the last 3 months - SearchParamConst.NOT_OLDER_3_MONTHS
Parameters:
selectedNotOlderRange - new SelectedNotOlderRange attribute
See Also:
getSelectedNotOlderRange()

getSelectedNotOlderRange

public java.lang.String getSelectedNotOlderRange()
Returns the current setting for the document time range.
See 'set' method for detailed information.
Returns:
current SelectedNotOlderRange attribute
See Also:
setSelectedNotOlderRange(java.lang.String)

setSelectedTitle

public void setSelectedTitle(java.lang.String value)
Sets the parameter that will be used to search only within the display name. Multiple values may be specified separated by commas.
The way of executing the search for the display name depends on the search string itself. The following are recognized as relevant properties: display name (Text), display name (String), access-Uri (String). The properties that are taken into account during the search are decided by the occurrence of the generic symbol "*" and an extension symbol ".".
Used practice is so far as follows:
"*" and "." -> display name (String) and access-uri
"*" or "." -> all properties
all other cases -> display name (String) and display name (Text)
Queries are connected by OR. Search method for search on display name (Text) is taken from the preset value. If no method is specified, 'best practice' is used.
Bear in mind that this method does not (!) enable you to search only for documents that start with a certain letter (e.g. "a*") in the display name.
The search method for search on the display name (type Text) is taken from the preset value. If no method is specified, 'best practice' is used.
The described behavior might be optimized in subsequent releases.
Parameters:
selectedTitle - new SelectedTitle attribute
See Also:
getSelectedTitle(), setSelectedSearchAction(java.lang.String)

getSelectedTitle

public java.lang.String getSelectedTitle()
Returns the current search setting for the selected display name/title of a document.
See 'set' method for detailed information.
Returns:
current SelectedTitle attribute
See Also:
setSelectedTitle(java.lang.String)

setSelectedDescription

public void setSelectedDescription(java.lang.String value)
Sets the parameter that will be used to search within the description. The search method for search on the description (type Text) is taken from the preset value. If no method is specified, 'best practice' is used.
Parameters:
selectedDescription - - new SelectedDescription attribute
See Also:
getSelectedDescription(), setSelectedSearchAction(java.lang.String)

getSelectedDescription

public java.lang.String getSelectedDescription()
Returns the current setting for the description condition of a document.
See 'set' method for detailed information.
Returns:
current SelectedDescription
See Also:
setSelectedDescription(java.lang.String)

setSelectedSimilarTerms

public void setSelectedSimilarTerms(java.lang.String value)
Sets similar terms string. Should contain additional search words as a comma- separated list. Terms are added to the normal term search.
Parameters:
value - new SelectedSimilarTerms attribute
See Also:
getSelectedSimilarTerms()

getSelectedSimilarTerms

public java.lang.String getSelectedSimilarTerms()
Returns the current setting for the similar terms condition.
See 'set' method for detailed information.
Returns:
current SelectedDescription attribute
See Also:
setSelectedSimilarTerms(java.lang.String)

setDisplaynameIncluded

public void setDisplaynameIncluded(boolean value)
Sets flag for search on display name during normal term search.
Default value: true.
Parameters:
value - new DisplaynameIncluded flag
See Also:
isDisplaynameIncluded(), setSearchTerm(java.lang.String)

isDisplaynameIncluded

public boolean isDisplaynameIncluded()
Returns the current setting for the display name included flag.
See 'set' method for detailed information.
Returns:
current DisplaynameIncluded flag
See Also:
setDisplaynameIncluded(boolean), setSearchTerm(java.lang.String)

setDescriptionIncluded

public void setDescriptionIncluded(boolean value)
Sets flag for search on description during normal term search.
Default value: true.
Parameters:
value - new DescriptionIncluded flag
See Also:
isDescriptionIncluded(), setSearchTerm(java.lang.String)

isDescriptionIncluded

public boolean isDescriptionIncluded()
Returns the current setting for the description included flag.
See 'set' method for detailed information.
Returns:
current DescriptionIncluded flag
See Also:
setDescriptionIncluded(boolean), setSearchTerm(java.lang.String)

setTermConnection

public void setTermConnection(java.lang.String value)
Sets mode for search terms query connection.
For example the search request for 'SAP NetWeaver Portal' consists of three search terms: SAP, NetWeaver and Portal. According to the TermConnections the search term queries are connected in different ways.
Possible values:
SearchParamsConst.TERM_CONNECTION_AND - query entries for single search terms are connected by AND
SearchParamsConst.TERM_CONNECTION_OR - query entries for single search terms are connected by OR
SearchParamsConst.TERM_CONNECTION_PHRASE - search request for the whole phrase is constructed
Default value: SearchParamsConst.TERM_CONNECTION_AND
Parameters:
value - new TermConnection mode
See Also:
getTermConnection()

getTermConnection

public java.lang.String getTermConnection()
Returns the current setting for term connection mode.
See 'set' method for detailed information.
Returns:
current TermConnection
See Also:
setTermConnection(java.lang.String)

setSearchParameters

public void setSearchParameters(java.util.Hashtable searchParameters)
Sets the search parameters by means of a hash table. In portal use, this comes directly from URL parameters (e.g. quick search, save-as-iView search etc). This method can also be used instead of providing all relevant values via 'set' methods.
The following parameters are supported so far (see also corresponding 'set' methods):
SearchParamConst.PARAM_SEARCH_TERM (String)
SearchParamConst.PARAM_SEARCH_ADD_PROPS (String)
SearchParamConst.PARAM_CUSTOM_PROPS (String)
SearchParamConst.PARAM_DESCRIPTION (String)
SearchParamConst.PARAM_NOT_OLDER_RANGE (String)
SearchParamConst.PARAM_TITLE (String)
SearchParamConst.PARAM_SEARCH_ACTION (String)
SearchParamConst.PARAM_SIMILAR_TERMS (String)
SearchParamConst.PARAM_ITEMS_SELECTION (String)
Parameters:
searchParameters - new SearchParameters table
See Also:
getSearchTerm(), getSearchAddProps(), getSelectedCustomProps(), getSelectedNotOlderRange(), getSelectedTitle(), getSelectedDescription(), getSelectedSearchAction(), getSelectedSimilarTerms(), getSelectedItems()

buildSearchQueryList

public IQueryEntryList buildSearchQueryList()
                                     throws WcmException
Central method for building query entry list that takes all set conditions into account. The returned query entry list has complete syntax and can be used directly for a search request against the KMC index management API.
In the simplest version of a search query entry list, the code could look like the following:

SearchQueryListBuilder searchQueryListBuilder = new searchQueryListBuilder();
searchQueryListBuilder.setSearchTerm(mySearchTerm);
IQueryEntryList queryEntryList = searchQueryListBuilder.buildSearchQueryEntryList();

This corresponds to the query entry list that is built for a normal quick search started from the portal header.
Returns:
IQueryEntryList
Throws:
WcmException -  
See Also:
SearchQueryListBuilder()

buildDidYouMeanQueryEntries

public IQueryEntryList buildDidYouMeanQueryEntries(IQueryEntryList oldQuery,
                                                   java.lang.String oldTerm,
                                                   java.lang.String didYouMeanTerm)
                                            throws WcmException
Provides an adapted new query entry list for a "Did You Mean" search. Should be used in combination with the method getDidYouMeanTerm.
Parameters:
oldQuery - old query entry list
oldTerm - old search term
didYouMeanTerm - new "Did you mean term"
Returns:
IQueryEntryList new "Did you mean" query entry list
Throws:
WcmException -  
See Also:
getDidYouMeanTerm(com.sapportals.wcm.service.indexmanagement.retrieval.search.IQueryEntryList, java.lang.String)

buildQueryEntryTimeWindow

public IQueryEntry buildQueryEntryTimeWindow(IPropertyName propertyName,
                                             java.util.Date startDate,
                                             java.util.Date endDate)
                                      throws WcmException
Simple method for building a time window query entry list.
Bear in mind that startDate and endDate need to be set.
The returned query entry list has complete syntax and can be connected, for example, by AND or OR.
Parameters:
propertyName - KM property name object that specifies attribute to be searched for
startDate - starting date of time window
endDate - ending date of time window
Returns:
IQueryEntryList new query entry list for time window search.
Throws:
WcmException -  

getBestSearchAction

public static byte getBestSearchAction(java.lang.String text)
Algorithmus that returns the 'best practice' search method. Possible values:
- EXACT for wildcards, quotation marks at start and end or only capital and non-lingustic chars (for example ABC$§&/())
- LINGUSITIC for at least one lingustic meaningful char (for example, abc)
Here, the byte code for building the single query entry is returned. In order to construct a 'best pactice' search query entry list, use the method setSelectedSearchAction with the parameter value SearchParamConst.ACTION_AUTOMATIC.
Parameters:
text - search term
Returns:
byte value of search method (example: IQueryEntry.TERM_ACTION_LINGUISTIC)
See Also:
setSelectedSearchAction(java.lang.String), getSelectedSearchAction()

getDidYouMeanTerm

public static java.lang.String getDidYouMeanTerm(IQueryEntryList queryEntryList,
                                                 java.lang.String oldSearchTerm)
                                          throws WcmException
Method extracts the "Did you mean" search term. The search must already have been executed by means of this query entry list. To get a new corresponding query entry list, use the method buildDidYouMeanQueryEntries.
Parameters:
queryEntryList - old query entry list
oldSearchTerm - old search term
Returns:
"Did you mean term"
Throws:
WcmException -  
See Also:
buildDidYouMeanQueryEntries(com.sapportals.wcm.service.indexmanagement.retrieval.search.IQueryEntryList, java.lang.String, java.lang.String)

buildQueryEntryConnector

public IQueryEntry buildQueryEntryConnector(java.lang.String connector)
                                     throws WcmException
Builds a single query entry that can be used as the connection between two query entry lists. The following operators can be specified as connectors so far:
IQueryEntry.OPERATOR_AND - AND connection
IQueryEntry.OPERATOR_OR - OR connection
IQueryEntry.OPERATOR_NOT - NOT connection

Connection has to be, for example, as follows:
...
SearchQueryListBuilder searchQueryListBuilder = new searchQueryListBuilder();
IQueryEntry queryEntryConnector = searchQueryListBuilder.buildQueryEntryConnector(IQueryEntry.OPERATOR_AND);
queryEntryList1.add(queryEntryConnector);
queryEntryList1.addAll(queryEntryList2);
...

Bear in mind that both query entry lists may not be empty and need to have correct syntax. If this is not the case, the resulting query entry list has incorrect syntax and will definitely cause errors when used for the search.
Parameters:
connector - Sting constant that specifies the connection operator (for exmample OR)
Returns:
Query entry containing connection operator
Throws:
WcmException -  
See Also:
buildSearchQueryList()

SAP NetWeaver '04

Copyright © 2004 by SAP AG. All Rights Reserved.
SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary.

These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.