Unix Technical Forum

Fulltext escape char

This is a discussion on Fulltext escape char within the MySQL forums, part of the Database Server Software category; --> Hi ng, I ve been search quite a while on the following problem but havent found a satisfactory solution ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 11:30 AM
IrrE
 
Posts: n/a
Default Fulltext escape char

Hi ng,

I ve been search quite a while on the following problem but havent
found a satisfactory solution yet.

I have a fulltext search which works fine in most cases, but if I
search for e.g. "herman-lons-weg" (SELECT ... FROM ... WHERE MATCH
(ADDRESS) AGAINST ('+herman-lons-weg' in boolean mode)), I ll receive
wrong results. I know the wrong are caused by the "-". I tried to
escape the "-" with "\" but that didnt help.

I also tried to put the whole phrase in literal strings AGAINST
('+"herman-lons-weg"' in boolean mode)) which worked fine for the
given term. But this way I would have no chance to search for "herman-
lons-*".

Anybody has an idea how to perform a fulltext search with words
containing operator-chars?

Thx in advance.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 11:30 AM
Captain Paralytic
 
Posts: n/a
Default Re: Fulltext escape char

On 18 Dec, 11:21, IrrE <smi...@googlemail.com> wrote:
> Hi ng,
>
> I ve been search quite a while on the following problem but havent
> found a satisfactory solution yet.
>
> I have a fulltext search which works fine in most cases, but if I
> search for e.g. "herman-lons-weg" (SELECT ... FROM ... WHERE MATCH
> (ADDRESS) AGAINST ('+herman-lons-weg' in boolean mode)), I ll receive
> wrong results. I know the wrong are caused by the "-". I tried to
> escape the "-" with "\" but that didnt help.
>
> I also tried to put the whole phrase in literal strings AGAINST
> ('+"herman-lons-weg"' in boolean mode)) which worked fine for the
> given term. But this way I would have no chance to search for "herman-
> lons-*".
>
> Anybody has an idea how to perform a fulltext search with words
> containing operator-chars?
>
> Thx in advance.


Here is the problem, how do you know whether the character is an
intentional operator character or a hyphen in a name?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 11:30 AM
IrrE
 
Posts: n/a
Default Re: Fulltext escape char

On 18 Dez., 12:38, Captain Paralytic <paul_laut...@yahoo.com> wrote:
> On 18 Dec, 11:21, IrrE <smi...@googlemail.com> wrote:
>
>
>
> > Hi ng,

>
> > I ve been search quite a while on the following problem but havent
> > found a satisfactory solution yet.

>
> > I have a fulltext search which works fine in most cases, but if I
> > search for e.g. "herman-lons-weg" (SELECT ... FROM ... WHERE MATCH
> > (ADDRESS) AGAINST ('+herman-lons-weg' in boolean mode)), I ll receive
> > wrong results. I know the wrong are caused by the "-". I tried to
> > escape the "-" with "\" but that didnt help.

>
> > I also tried to put the whole phrase in literal strings AGAINST
> > ('+"herman-lons-weg"' in boolean mode)) which worked fine for the
> > given term. But this way I would have no chance to search for "herman-
> > lons-*".

>
> > Anybody has an idea how to perform a fulltext search with words
> > containing operator-chars?

>
> > Thx in advance.

>
> Here is the problem, how do you know whether the character is an
> intentional operator character or a hyphen in a name?


Per contract the input is always treated as a hyphen.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-28-2008, 11:30 AM
Captain Paralytic
 
Posts: n/a
Default Re: Fulltext escape char

On 18 Dec, 11:40, IrrE <smi...@googlemail.com> wrote:
> On 18 Dez., 12:38, Captain Paralytic <paul_laut...@yahoo.com> wrote:
>
>
>
> > On 18 Dec, 11:21, IrrE <smi...@googlemail.com> wrote:

>
> > > Hi ng,

>
> > > I ve been search quite a while on the following problem but havent
> > > found a satisfactory solution yet.

>
> > > I have a fulltext search which works fine in most cases, but if I
> > > search for e.g. "herman-lons-weg" (SELECT ... FROM ... WHERE MATCH
> > > (ADDRESS) AGAINST ('+herman-lons-weg' in boolean mode)), I ll receive
> > > wrong results. I know the wrong are caused by the "-". I tried to
> > > escape the "-" with "\" but that didnt help.

>
> > > I also tried to put the whole phrase in literal strings AGAINST
> > > ('+"herman-lons-weg"' in boolean mode)) which worked fine for the
> > > given term. But this way I would have no chance to search for "herman-
> > > lons-*".

>
> > > Anybody has an idea how to perform a fulltext search with words
> > > containing operator-chars?

>
> > > Thx in advance.

>
> > Here is the problem, how do you know whether the character is an
> > intentional operator character or a hyphen in a name?

>
> Per contract the input is always treated as a hyphen.


Then just translate all hyphens to spaces before presenting it to the
query.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-28-2008, 11:30 AM
IrrE
 
Posts: n/a
Default Re: Fulltext escape char

On 18 Dez., 13:24, Captain Paralytic <paul_laut...@yahoo.com> wrote:
> On 18 Dec, 11:40, IrrE <smi...@googlemail.com> wrote:
>
>
>
> > On 18 Dez., 12:38, Captain Paralytic <paul_laut...@yahoo.com> wrote:

>
> > > On 18 Dec, 11:21, IrrE <smi...@googlemail.com> wrote:

>
> > > > Hi ng,

>
> > > > I ve been search quite a while on the following problem but havent
> > > > found a satisfactory solution yet.

>
> > > > I have a fulltext search which works fine in most cases, but if I
> > > > search for e.g. "herman-lons-weg" (SELECT ... FROM ... WHERE MATCH
> > > > (ADDRESS) AGAINST ('+herman-lons-weg' in boolean mode)), I ll receive
> > > > wrong results. I know the wrong are caused by the "-". I tried to
> > > > escape the "-" with "\" but that didnt help.

>
> > > > I also tried to put the whole phrase in literal strings AGAINST
> > > > ('+"herman-lons-weg"' in boolean mode)) which worked fine for the
> > > > given term. But this way I would have no chance to search for "herman-
> > > > lons-*".

>
> > > > Anybody has an idea how to perform a fulltext search with words
> > > > containing operator-chars?

>
> > > > Thx in advance.

>
> > > Here is the problem, how do you know whether the character is an
> > > intentional operator character or a hyphen in a name?

>
> > Per contract the input is always treated as a hyphen.

>
> Then just translate all hyphens to spaces before presenting it to the
> query.


I already thought about that solution, but it wont work:

If I had the following entries in the database...

1. herman
2. löns
3. herman lons
4. herman-lons

...and the following seach-term "herman-lons" which would be
translated into "+herman +lons"...
I would get the results 3 and 4. But the correct result would only be
#4.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-28-2008, 11:30 AM
Captain Paralytic
 
Posts: n/a
Default Re: Fulltext escape char

On 18 Dec, 13:21, IrrE <smi...@googlemail.com> wrote:
> On 18 Dez., 13:24, Captain Paralytic <paul_laut...@yahoo.com> wrote:
>
>
>
> > On 18 Dec, 11:40, IrrE <smi...@googlemail.com> wrote:

>
> > > On 18 Dez., 12:38, Captain Paralytic <paul_laut...@yahoo.com> wrote:

>
> > > > On 18 Dec, 11:21, IrrE <smi...@googlemail.com> wrote:

>
> > > > > Hi ng,

>
> > > > > I ve been search quite a while on the following problem but havent
> > > > > found a satisfactory solution yet.

>
> > > > > I have a fulltext search which works fine in most cases, but if I
> > > > > search for e.g. "herman-lons-weg" (SELECT ... FROM ... WHERE MATCH
> > > > > (ADDRESS) AGAINST ('+herman-lons-weg' in boolean mode)), I ll receive
> > > > > wrong results. I know the wrong are caused by the "-". I tried to
> > > > > escape the "-" with "\" but that didnt help.

>
> > > > > I also tried to put the whole phrase in literal strings AGAINST
> > > > > ('+"herman-lons-weg"' in boolean mode)) which worked fine for the
> > > > > given term. But this way I would have no chance to search for "herman-
> > > > > lons-*".

>
> > > > > Anybody has an idea how to perform a fulltext search with words
> > > > > containing operator-chars?

>
> > > > > Thx in advance.

>
> > > > Here is the problem, how do you know whether the character is an
> > > > intentional operator character or a hyphen in a name?

>
> > > Per contract the input is always treated as a hyphen.

>
> > Then just translate all hyphens to spaces before presenting it to the
> > query.

>
> I already thought about that solution, but it wont work:
>
> If I had the following entries in the database...
>
> 1. herman
> 2. löns
> 3. herman lons
> 4. herman-lons
>
> ...and the following seach-term "herman-lons" which would be
> translated into "+herman +lons"...
> I would get the results 3 and 4. But the correct result would only be
> #4.


Aer you sure hat the fulltext indexing process does not ignore the
hyphen in the name anyway?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 02-28-2008, 11:30 AM
IrrE
 
Posts: n/a
Default Re: Fulltext escape char

On 18 Dez., 14:34, Captain Paralytic <paul_laut...@yahoo.com> wrote:
> On 18 Dec, 13:21, IrrE <smi...@googlemail.com> wrote:
>
>
>
> > On 18 Dez., 13:24, Captain Paralytic <paul_laut...@yahoo.com> wrote:

>
> > > On 18 Dec, 11:40, IrrE <smi...@googlemail.com> wrote:

>
> > > > On 18 Dez., 12:38, Captain Paralytic <paul_laut...@yahoo.com> wrote:

>
> > > > > On 18 Dec, 11:21, IrrE <smi...@googlemail.com> wrote:

>
> > > > > > Hi ng,

>
> > > > > > I ve been search quite a while on the following problem but havent
> > > > > > found a satisfactory solution yet.

>
> > > > > > I have a fulltext search which works fine in most cases, but if I
> > > > > > search for e.g. "herman-lons-weg" (SELECT ... FROM ... WHERE MATCH
> > > > > > (ADDRESS) AGAINST ('+herman-lons-weg' in boolean mode)), I ll receive
> > > > > > wrong results. I know the wrong are caused by the "-". I tried to
> > > > > > escape the "-" with "\" but that didnt help.

>
> > > > > > I also tried to put the whole phrase in literal strings AGAINST
> > > > > > ('+"herman-lons-weg"' in boolean mode)) which worked fine for the
> > > > > > given term. But this way I would have no chance to search for "herman-
> > > > > > lons-*".

>
> > > > > > Anybody has an idea how to perform a fulltext search with words
> > > > > > containing operator-chars?

>
> > > > > > Thx in advance.

>
> > > > > Here is the problem, how do you know whether the character is an
> > > > > intentional operator character or a hyphen in a name?

>
> > > > Per contract the input is always treated as a hyphen.

>
> > > Then just translate all hyphens to spaces before presenting it to the
> > > query.

>
> > I already thought about that solution, but it wont work:

>
> > If I had the following entries in the database...

>
> > 1. herman
> > 2. löns
> > 3. herman lons
> > 4. herman-lons

>
> > ...and the following seach-term "herman-lons" which would be
> > translated into "+herman +lons"...
> > I would get the results 3 and 4. But the correct result would only be
> > #4.

>
> Aer you sure hat the fulltext indexing process does not ignore the
> hyphen in the name anyway?


Yes you are right. The hypen is ignored anyway. Thanks for the hint :-)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 02-28-2008, 11:30 AM
Captain Paralytic
 
Posts: n/a
Default Re: Fulltext escape char

On 18 Dec, 14:38, IrrE <smi...@googlemail.com> wrote:
> On 18 Dez., 14:34, Captain Paralytic <paul_laut...@yahoo.com> wrote:
>
>
>
> > On 18 Dec, 13:21, IrrE <smi...@googlemail.com> wrote:

>
> > > On 18 Dez., 13:24, Captain Paralytic <paul_laut...@yahoo.com> wrote:

>
> > > > On 18 Dec, 11:40, IrrE <smi...@googlemail.com> wrote:

>
> > > > > On 18 Dez., 12:38, Captain Paralytic <paul_laut...@yahoo.com> wrote:

>
> > > > > > On 18 Dec, 11:21, IrrE <smi...@googlemail.com> wrote:

>
> > > > > > > Hi ng,

>
> > > > > > > I ve been search quite a while on the following problem but havent
> > > > > > > found a satisfactory solution yet.

>
> > > > > > > I have a fulltext search which works fine in most cases, but if I
> > > > > > > search for e.g. "herman-lons-weg" (SELECT ... FROM ... WHERE MATCH
> > > > > > > (ADDRESS) AGAINST ('+herman-lons-weg' in boolean mode)), I ll receive
> > > > > > > wrong results. I know the wrong are caused by the "-". I triedto
> > > > > > > escape the "-" with "\" but that didnt help.

>
> > > > > > > I also tried to put the whole phrase in literal strings AGAINST
> > > > > > > ('+"herman-lons-weg"' in boolean mode)) which worked fine for the
> > > > > > > given term. But this way I would have no chance to search for "herman-
> > > > > > > lons-*".

>
> > > > > > > Anybody has an idea how to perform a fulltext search with words
> > > > > > > containing operator-chars?

>
> > > > > > > Thx in advance.

>
> > > > > > Here is the problem, how do you know whether the character is an
> > > > > > intentional operator character or a hyphen in a name?

>
> > > > > Per contract the input is always treated as a hyphen.

>
> > > > Then just translate all hyphens to spaces before presenting it to the
> > > > query.

>
> > > I already thought about that solution, but it wont work:

>
> > > If I had the following entries in the database...

>
> > > 1. herman
> > > 2. löns
> > > 3. herman lons
> > > 4. herman-lons

>
> > > ...and the following seach-term "herman-lons" which would be
> > > translated into "+herman +lons"...
> > > I would get the results 3 and 4. But the correct result would only be
> > > #4.

>
> > Aer you sure hat the fulltext indexing process does not ignore the
> > hyphen in the name anyway?

>
> Yes you are right. The hypen is ignored anyway. Thanks for the hint :-)


Did you do a google search for
mysql fulltext hyphen
before you poted here?
If so you would have seen a discussion on this in the manual.
You would have saved yourself a lot of time!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:18 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com