|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.arsdigita.search.intermedia.SearchSpecification
com.arsdigita.search.intermedia.SimpleSearchSpecification
This class provides methods to make it easier to specify a search. These methods may be used in two ways, depending on the complexity of the search.
If the search is simple (searching for a single string in either the xml or raw content fields, with no joined tables, and only the standard fields selected) then a SimpleSearchSpecification object can be created to do the search. Search results can then be accessed by method getSearchPage. This allows using accessor methods in class SearchDataQuery to easily retrieve the returned fields.
If the search cannot be done by creating a
SimpleSearchSpecification
object, then
the more general SearchSpecification
object will have to be created to do the search.
However, in that case, two static methods in
this class (cleanSearchString
and
containsClause
)
can be used to help build the search query that
is passed into SearchSpecification
.
Searchable
,
SearchSpecification
,
SearchDataQuery
Field Summary | |
static String |
versionId
|
Constructor Summary | |
SimpleSearchSpecification(String searchString)
Create a SimpleSearchSpecification object to search for objects of any type that contain the specified searchString. |
|
SimpleSearchSpecification(String object_type,
String searchString)
Create a SimpleSearchSpecification object to search for objects of the given type that contain the specified searchString. |
Method Summary | |
static String |
cleanSearchString(String searchString,
String joinString)
Cleanup the search string by removing characters |&,-*;{}%_$?!()\:@.<>#^+=[]~` and by combining multiple words with a join string. |
static String |
containsClause(String sc,
String searchString,
String xml_label,
String raw_label)
Build a containsClause for a search query. |
DataQuery |
getPage(int page)
Execute a search, returning a page of search results. |
SearchDataQuery |
getSearchPage(int page)
Similar to getPage but returns results as a SearchDataQuery object. |
void |
setSelect(String sql,
String[] columns)
Set the Sql select statement and columns used to do a search. |
Methods inherited from class com.arsdigita.search.intermedia.SearchSpecification |
getColumns, getMaxResultRows, getParameter, getRowsPerPage, getSelect, reformatSqlForPage, setMaxResultRows, setParameter, setRowsPerPage |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String versionId
Constructor Detail |
public SimpleSearchSpecification(String object_type, String searchString)
object_type
- The type of object to search.searchString
- The string to search for.public SimpleSearchSpecification(String searchString)
searchString
- The string to search for.Method Detail |
public static String containsClause(String sc, String searchString, String xml_label, String raw_label)
(contains(sc.xml_content, 'searchString', xml_label) > 0 OR contains(sc.raw_content, 'searchString', raw_label) > 0)
Specifying null for either the label parameters inhibits the generation of the contains clause for the corresponding column. For example, if the xml_label was null, only the contains for the raw_content field would be generated. If both xml_label and raw_label are null an empty string is returned.
sc
- alias for search_content table name. For example, if
the query contained:
select ... from search_content c ...then sc would be the string "c".
searchString
- The string to be searched. It should have either
been processed by cleanSearchString
before being
passed into this method or otherwise known not to contain invalid
characters or words.
Single quote characters (i.e. ') are allowed in the search string
(each single quote character is escaped by replacing it with two
single quote characters when the contains clause is generated).xml_label
- A label used to identify the score for matching on
the xml_content field. Would normally be "1". If null, then the
contains clause for the xml_content field is not created.raw_label
- A label used to identify the score for matching on
the raw_content field. Would normally be "2". If null, then the
contains clause for the raw_content field is not created.
public static String cleanSearchString(String searchString, String joinString)
searchString
- Input search string to be cleaned.joinString
- The join string. Normally this will be " and " to generate
a search for objects containing all words in the searchString.
public void setSelect(String sql, String[] columns)
SearchSpecification
setSelect
in class SearchSpecification
sql
- Sql select statement to perform the search. See
example above.columns
- The names of columns returned by the
search.public DataQuery getPage(int page)
getPage
in class SearchSpecification
page
- The page of search results to retrieve
(page==1 means first page).public SearchDataQuery getSearchPage(int page)
page
- The page of search results to retrieve
(page==1 means first page).
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |