Oracle 5.0 Reference Manual page 956

Table of Contents

Advertisement

By default, the search is performed in case-insensitive fashion. However, you can perform a case-
sensitive full-text search by using a binary collation for the indexed columns. For example, a column
that uses the
character set of can be assigned a collation of
latin1
sensitive for full-text searches.
When
[934]
is used in a
MATCH()
are automatically sorted with the highest relevance first. Relevance values are nonnegative floating-
point numbers. Zero relevance means no similarity. Relevance is computed based on the number of
words in the row, the number of unique words in that row, the total number of words in the collection,
and the number of documents (rows) that contain a particular word.
To simply count matches, you could use a query like this:
mysql>
SELECT COUNT(*) FROM articles
->
WHERE MATCH (title,body)
->
AGAINST ('database');
+----------+
| COUNT(*) |
+----------+
|
2 |
+----------+
1 row in set (0.00 sec)
However, you might find it quicker to rewrite the query as follows:
mysql>
SELECT
->
COUNT(IF(MATCH (title,body) AGAINST ('database'), 1, NULL))
->
AS count
->
FROM articles;
+-------+
| count |
+-------+
|
2 |
+-------+
1 row in set (0.00 sec)
The first query sorts the results by relevance whereas the second does not. However, the second
query performs a full table scan and the first does not. The first may be faster if the search matches few
rows; otherwise, the second may be faster because it would read many rows anyway.
For natural-language full-text searches, it is a requirement that the columns named in the
[934]
function be the same columns included in some
MATCH()
the preceding query, note that the columns named in the
are the same as those named in the definition of the
to search the
or
title
each column.
It is also possible to perform a boolean search or a search with query expansion. These search types
are described in
Section 12.9.2, "Boolean Full-Text
with Query
Expansion".
A full-text search that uses an index can name columns only from a single table in the
clause because an index cannot span multiple tables. A boolean search can be done in the absence of
an index (albeit more slowly), in which case it is possible to name columns from multiple tables.
The preceding example is a basic illustration that shows how to use the
where rows are returned in order of decreasing relevance. The next example shows how to retrieve the
relevance values explicitly. Returned rows are not ordered because the
neither
nor
WHERE
ORDER BY
mysql>
SELECT id, MATCH (title,body) AGAINST ('Tutorial')
->
FROM articles;
+----+-----------------------------------------+
| id | MATCH (title,body) AGAINST ('Tutorial') |
+----+-----------------------------------------+
|
1 |
Natural Language Full-Text Searches
clause, as in the example shown earlier, the rows returned
WHERE
separately, you would need to create separate
body
clauses:
0.65545833110809 |
936
latin1_bin
FULLTEXT
[934]
function
MATCH()
table's
article
FULLTEXT
Searches", and
Section 12.9.3, "Full-Text Searches
MATCH()
SELECT
to make it case
index in your table. For
(title
and body)
index. If you wanted
indexes for
FULLTEXT
[934]
MATCH()
[934]
function
statement includes

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents