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 ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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. |
| |||
| 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? |
| |||
| 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. |
| |||
| 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. |
| |||
| 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. |
| |||
| 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? |
| |||
| 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 :-) |
| ||||
| 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! |