|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.arsdigita.search.intermedia.SearchSpecification
This class is used to perform a search for content that has been indexed. Indexing of content is described in Searchable interface documentation.
To perform a search, there are two steps:
getPage
to return each page of search
results.
The main task is the specification of the SQL Select
statement. The SQL select statement should query the
search_content
table, and perhaps other
joined tables. The following are the fields in the
search_content
table:
object_id integer primary key, references acs_objects (object_id) object_type varchar2(100), -- Same as acs_objects(object_type) link_text varchar2(1000), url_stub varchar2(100), summary varchar2(4000), xml_content clob, raw_content blob, language varchar2(3)
Fields xml_content
and raw_content
contain the content that is indexed. Searching for content
is done by selecting from these columns using the Oracle
"contains" function. The xml_content field allows using the
"within" operator to search for content within specified
XML elements.
Example. Suppose an object has the following content indexed:
xml_content: <Article> <title>Market Research</title> <author>Ernest Johnston</author> </Article> raw_content: Focus groups indicate ambivalence.and that another table (article_info) has a field (publish_date) which indicates the date the article was published.
Then the following SQL statement could be used to search for a query string in the <title> attribute or raw_content field for articles that were published earler than the current date and order the results. '$queryString' symbolizes where the query string would be placed.
select object_id, link_text, url_stub, summary, score(1)+score(2) as score from search_content sc, article_info ai where (contains(xml_content, '$queryString within title', 1) > 0 or contains(raw_content, '$queryString', 2) > 0) and ai.publish_date < sysdate and ai.article_id = sc.object_id order by score descThe columns that would need to be specified to the constructor are: object_id, link_text, url_stub, summary and score. They query would find the example object if the queryString was "market" or "ambivalence" (respectively through the title attribute and raw_content field) but not if the query string was "Ernest" since the author section is not searched. All attributes in the xml_content field can be searched by not including a "within" clause. Details of of the Oracle interMedia contains, within and score functions are described in Oracle8i Application Developer's Guide - XML and in Oracle8i interMedia Text Reference.
SearchDataQuery
Field Summary | |
static String |
versionId
|
Constructor Summary | |
SearchSpecification(String sql,
String[] columns)
Create a SearchSpecification object, using the default values for maxRows and rowsPerPage. |
|
SearchSpecification(String sql,
String[] columns,
int maxRows,
int rowsPerPage)
Create a SearchSpecification object. |
Method Summary | |
String[] |
getColumns()
Get the columns names that the sql select returns. |
int |
getMaxResultRows()
Get the maximum number of result rows that can be retrieved by the search. |
DataQuery |
getPage(int page)
Execute a search, returning a page of search results. |
Object |
getParameter(String parameterName)
Allows a caller to get a parameter value for a parameter that has already been set |
int |
getRowsPerPage()
Get the maximum number of rows per result page returned by method getPage. |
String |
getSelect()
Get the Sql select statement used to do a search. |
protected String |
reformatSqlForPage(int page)
Build a new sql select statement, that is reformatted to select the specified page. |
void |
setMaxResultRows(int maxRows)
Set the maximum number of result rows retrieved by the search. |
void |
setParameter(String name,
Object value)
Allows a user to bind a parameter within the query. |
void |
setRowsPerPage(int rowsPerPage)
Set the maximum number of result rows retrieved by the search. |
void |
setSelect(String sql,
String[] columns)
Set the Sql select statement and columns used to do a search. |
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 SearchSpecification(String sql, String[] columns, int maxRows, int rowsPerPage)
sql
- Sql select statement to perform the search. See
example above.columns
- The names of columns returned by the
search.maxRows
- The maximum number of result rows retrieved
by the search.rowsPerPage
- The maximum number of rows per result
page returned by method getPage.public SearchSpecification(String sql, String[] columns)
sql
- Sql select statement to perform the search. See
example above.columns
- The names of columns returned by the
search.Method Detail |
public void setParameter(String name, Object value)
name
- The name of the parameter to bindvalue
- The value to assign to the parameterpublic Object getParameter(String parameterName)
parameterName
- The name of the parameter to retrieve
public void setSelect(String sql, String[] columns)
sql
- Sql select statement to perform the search. See
example above.columns
- The names of columns returned by the
search.public void setMaxResultRows(int maxRows)
maxRows
- The maximum number of result rows
retrieved by the search.public void setRowsPerPage(int rowsPerPage)
rowsPerPage
- The maximum number of rows per result
page returned by method getPage.public String getSelect()
public String[] getColumns()
public int getMaxResultRows()
public int getRowsPerPage()
protected String reformatSqlForPage(int page)
Example usage.
Input:
select id, name from result_info order by substr(name,2,3)
Output:
select * from (select temp_view.*, rownum as temp_rownum from (select id, name from result_info order by substr(name,2,3)) temp_view) where temp_rownum >= firstRow and temp_rownum <= lastRow
Notes:
public DataQuery getPage(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 |