dbTalk Databases Forums  

Fulltext usage

comp.databases.mysql comp.databases.mysql


Discuss Fulltext usage in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
gervaz
 
Posts: n/a

Default Fulltext usage - 06-21-2011 , 04:37 AM






Hi all, I created a table with the following definition:

CREATE TABLE word_table (
id int(10) unsigned NOT NULL auto_increment,
word text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
PRIMARY KEY (id)
)

The 'word' column contains just one-word values. I want to access this
values using a dictionary for speedup reasons, and as far as I know I
should index the column, using FULLTEXT KEY (word), but this are my
concerns:
- in order to access the 'word' column values, I'll have to use
MATCH() AGAINST(), or a normal WHERE 'word' = {} should work?
- how does the fulltext work? I just have single values, and I know
that there is a 'score' provided by mySQL, does it means that if the
word is not found, I always get something or can I enforce a
"dictionary-like" behaviour?

Thanks,

Mattia

Reply With Quote
  #2  
Old   
Axel Schwenke
 
Posts: n/a

Default Re: Fulltext usage - 06-21-2011 , 05:21 AM






gervaz <gervaz (AT) gmail (DOT) com> wrote:

Quote:
Hi all, I created a table with the following definition:

CREATE TABLE word_table (
id int(10) unsigned NOT NULL auto_increment,
word text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
PRIMARY KEY (id)
)

The 'word' column contains just one-word values.
So why did you chose the type TEXT for that column? Would not
VARCHAR(20) (or alike) be a much better choice?

Quote:
I want to access this
values using a dictionary for speedup reasons, and as far as I know I
should index the column, using FULLTEXT KEY (word),
A FULLTEXT index is *not* a dictionary.

Quote:
but this are my concerns:
- in order to access the 'word' column values, I'll have to use
MATCH() AGAINST(), or a normal WHERE 'word' = {} should work?
In order to make MySQL use the FULLTEXT index, you have to use the
MATCH syntax. But of course this makes no sense if you look for an
exact match.

It all depends on what operations you plan to do. But for exact
matches (... WHERE word = 'foobar') or head matching (... WHERE
word LIKE 'foo%') a normal BTREE index would be perfect.

Quote:
- how does the fulltext work?
Fulltext search is about proximity (opposed to exact) matching.
This makes little sense for single words. There are methods like
SOUNDEX() or n-gram matching (not in MySQL) though. The score (or
rank) is a measure how close a document is to the search term.

Especially MySQL FULLTEXT indexing is not at all useful to match
"documents" consisting of a single word only.


XL

Reply With Quote
  #3  
Old   
gervaz
 
Posts: n/a

Default Re: Fulltext usage - 06-21-2011 , 02:49 PM



On 21 Giu, 12:21, Axel Schwenke <axel.schwe... (AT) gmx (DOT) de> wrote:
Quote:
gervaz <ger... (AT) gmail (DOT) com> wrote:
Hi all, I created a table with the following definition:

CREATE TABLE word_table (
* * id int(10) unsigned NOT NULL auto_increment,
* * word text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
* * PRIMARY KEY (id)
)

The 'word' column contains just one-word values.

So why did you chose the type TEXT for that column? Would not
VARCHAR(20) (or alike) be a much better choice?

I want to access this
values using a dictionary for speedup reasons, and as far as I know I
should index the column, using FULLTEXT KEY (word),

A FULLTEXT index is *not* a dictionary.

but this are my concerns:
- in order to access the 'word' column values, I'll have to use
MATCH() AGAINST(), or a normal WHERE 'word' = {} should work?

In order to make MySQL use the FULLTEXT index, you have to use the
MATCH syntax. But of course this makes no sense if you look for an
exact match.

It all depends on what operations you plan to do. But for exact
matches (... WHERE word = 'foobar') or head matching (... WHERE
word LIKE 'foo%') a normal BTREE index would be perfect.

- how does the fulltext work?

Fulltext search is about proximity (opposed to exact) matching.
This makes little sense for single words. There are methods like
SOUNDEX() or n-gram matching (not in MySQL) though. The score (or
rank) is a measure how close a document is to the search term.

Especially MySQL FULLTEXT indexing is not at all useful to match
"documents" consisting of a single word only.

XL
Thank you Alex! Great explanation.

Mattia

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.