Databases Reference
In-Depth Information
You can set an automatic update frequency for text indexes based on either or
both the time of update and the minimum number of changes picked up from the
log table (incremental changes are stored in the log table):
db2text ALTER INDEX movietext FOR TEXT UPDATE FREQUENCY d(1,2,3,4,5)
h(12,15) m(00) UPDATE MINIMUM 100
There are three types of full-text search supported by NSE:
SQL scalar search function: SQL function for general text search application.
SQL table-valued function: This supports general text search on presorted
indexes and views.
Text search stored procedure: This can be used for a high performance
dedicated text search.
Among these three methods, we recommend SQL scalar function search for
your search method and it is useful for most situations. You can integrate SQL
search functions with DB2 optimizer for excellent performance where JOIN of
data is needed. The basic syntax is:
SELECT column FROM table WHERE CONTAINS(column-name,
'search-criteria')=1
The following query exploits the index created in step 2 previously but restricts it
to a specific element. The query retrieves all documents where the element
/movie/movie-details/genres contains the word Comedy :
select movieDetails from movies where contains(movieDetails, 'sections
(“/movie/movie-details/genres”) “Comedy”') =1
The following example shows the use of full-text search function with xquery:
for $i in db2-fn:sqlquery('
SELECT movieDetails FROM movies
WHERE CONTAINS('movieDetails,
SECTION(“movie/title") “Dupree”)=1')//movie/title
return $i
The following example shows the use of full-text search function with SQL or
XML:
SELECT XMLQUERY('$t//movie/title' PASSING T.TITLE AS \"t\" )
FROM movies AS t
WHERE CONTAINS('movieDetails,
SECTION(“movie/title") “Dupree”)=1
To summarize, DB2 full-text search can help your application find relevant data
based on structural and full-text search parameters. You can create and maintain
Search WWH ::




Custom Search