RE: [PHP] pattern matching mysql4
| From: | John Holmes | Date: | Mon, 17 Jun 2002 03:43:16 +0000 |
| Subject: | RE: [PHP] pattern matching mysql4 | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-102464@lists.php.net to get a copy of this message | ||
Took me less than a minute to find this in the manual...Chapter 6.8
As of Version 4.0.1, MySQL can also perform boolean full-text searches
using the IN BOOLEAN MODE modifier.
mysql> SELECT * FROM articles WHERE MATCH (title,body)
-> AGAINST ('+MySQL -YourSQL' IN BOOLEAN MODE);
+----+------------------------------+-----------------------------------
--+
| id | title | body
|
+----+------------------------------+-----------------------------------
--+
| 1 | MySQL Tutorial | DBMS stands for DataBase ...
|
| 2 | How To Use MySQL Efficiently | After you went through a ...
|
| 3 | Optimising MySQL | In this tutorial we will show ...
|
| 4 | 1001 MySQL Trick | 1. Never run mysqld as root. 2.
... |
| 6 | MySQL Security | When configured properly, MySQL
... |
+----+------------------------------+-----------------------------------
--+
This query retrieved all the rows that contain the word MySQL (note: the
50% threshold is not used), but that do not contain the word YourSQL.
Note that a boolean mode search does not auto-magically sort rows in
order of decreasing relevance. You can see this from result of the
preceding query, where the row with the highest relevance (the one that
contains MySQL twice) is listed last, not first. A boolean full-text
search can also work even without a FULLTEXT index, although it would be
slow.
The boolean full-text search capability supports the following
operators:
+
A leading plus sign indicates that this word must be present in every
row returned.
-
A leading minus sign indicates that this word must not be present in any
row returned.
By default (when neither plus nor minus is specified) the word is
optional, but the rows that contain it will be rated higher. This
mimicks the behaviour of MATCH() ... AGAINST() without the IN BOOLEAN
MODE modifier.
< >
These two operators are used to change a word's contribution to the
relevance value that is assigned to a row. The < operator decreases the
contribution and the > operator increases it. See the example below.
( )
Parentheses are used to group words into subexpressions.
~
A leading tilde acts as a negation operator, causing the word's
contribution to the row relevance to be negative. It's useful for
marking noise words. A row that contains such a word will be rated lower
than others, but will not be excluded altogether, as it would be with
the - operator.
*
An asterisk is the truncation operator. Unlike the other operators, it
should be appended to the word, not prepended.
"
The phrase, that is enclosed in double quotes ", matches only rows that
contain this phrase literally, as it was typed.
And here are some examples:
apple banana
find rows that contain at least one of these words.
+apple +juice
... both words.
+apple macintosh
... word `
apple'', but rank it higher if it also contain
`macintosh''.
+apple -macintosh
... word `apple'' but not `macintosh''.
+apple +(>pie <strudel)
... `apple'' and pie'', or apple'' and
`strudel'' (in any order),
but rank `apple pie'' higher than `apple strudel''.
apple*
... `apple'', apples'', applesauce'',
and `applet''.
"some words"
... `some words of wisdom'', but not `some noise words''.
---John Holmes...
> -----Original Message-----
> From: John Taylor-Johnston [mailto:taylorjo@collegesherbrooke.qc.ca]
> Sent: Sunday, June 16, 2002 11:37 PM
> To: php-general@lists.php.net
> Subject: Re: [PHP] pattern matching mysql4
>
> >Yeah, I'm thinking you might want to ask this on a MySQL list...
> >John Holmes
>
> Like if I could find one that I don't have to receive 100 emails to
get an
> answer :o)
> So I ask my friends here who might know what I am looking for. It's
for
> PHP coding anyways.
> John, tell me where to find a newsgroup, not a mailing list and I
would be
> happy. My news reader cannot find one that speaks English.
>
> I heard there was a new boolean search in MySQL 4 ...
>
> that replaces "... where name like 'john' ..."
> that would parse my searchenquiry if I entered "+john +mary"
> that I would not have to code for "john AND mary" anymore.
>
> I cannot remember the keyword I'm looking for, something to replace
'like'
> ?
>
> John
>
> John Holmes wrote:
>
> > Yeah, I'm thinking you might want to ask this on a MySQL list...
> >
> > PHP != MySQL
> >
> > ---John Holmes...
> >
> > > -----Original Message-----
> > > From: John Taylor-Johnston
[mailto:taylorjo@collegesherbrooke.qc.ca]
> > > Sent: Sunday, June 16, 2002 6:13 PM
> > > To: php-general@lists.php.net
> > > Subject: [PHP] pattern matching mysql4
> > >
> > > pattern matching mysql4
> > >
> > > Someone told me mysql4 has boolaen searching built in as well as
other
> > > pattern matching options. What are they? How do they work? I
searched
> > > around
> > > mysql.org but found nothing much to satisfy my curiosity.
> > >
> > > Anyone have a link? :o)
> > >
> > > John
> > >
> > >
> >
------------------------------------------------------------------------
> > --
> > > ---
> > > - Université de Sherbrooke:
> > > http_colon_//compcanlit_dot_ca/
> > >
> > >
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php