[php & MySQL] Full-text Search werkt niet echt

Pagina: 1
Acties:

Onderwerpen


Acties:
  • 0 Henk 'm!

  • Liqued
  • Registratie: Februari 2001
  • Laatst online: 06-08 15:21
Ik heb in php een zoekmachine gemaakt met behulp van MySQL Full-text Search. Nu is het zo dat het wel werkt op de ene tabel en niet op de ander en ik begrijp niet waarom.

Hier de tabellen
SQL:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
CREATE TABLE `filmrecensies` (
  `id` int(11) NOT NULL auto_increment,
  `gebruikersid` varchar(11) NOT NULL default '',
  `datum` timestamp(14) NOT NULL,
  `filmnaam` varchar(255) NOT NULL default '',
  `recensie` text NOT NULL,
  `beoordelingauteur` int(2) NOT NULL default '0',
  `totalebeoordelinggebruikers` int(11) NOT NULL default '0',
  `aantalstemmengebruikers` int(11) NOT NULL default '0',
  `url` varchar(255) NOT NULL default '',
  PRIMARY KEY  (`id`),
  KEY `gebruikersid` (`gebruikersid`),
  FULLTEXT KEY `filmnaam` (`filmnaam`,`recensie`),
  KEY `datum` (`datum`)
) TYPE=MyISAM AUTO_INCREMENT=7 ;


CREATE TABLE `filmnieuws` (
  `id` int(11) NOT NULL auto_increment,
  `gebruikersid` int(11) NOT NULL default '0',
  `datum` timestamp(14) NOT NULL,
  `filmnieuwstitel` varchar(255) NOT NULL default '',
  `nieuws` mediumtext NOT NULL,
  `bronnaam` varchar(255) NOT NULL default '',
  `bronurl` text NOT NULL,
  PRIMARY KEY  (`id`),
  FULLTEXT KEY `filmnieuwstitel` (`filmnieuwstitel`,`nieuws`),
  KEY `gebruikersid` (`gebruikersid`),
  KEY `datum` (`datum`)
) TYPE=MyISAM AUTO_INCREMENT=5 ;


Hier de queries die ik gebruik:
$query = "SELECT id, gebruikersid, datum, filmnaam, MATCH (`recensie`, `filmnaam`) AGAINST ('$zoekstring') AS score FROM filmrecensies WHERE MATCH (`recensie`, `filmnaam`) AGAINST ('$zoekstring')";

$query = "SELECT id, gebruikersid, datum, filmnieuwstitel, nieuws, MATCH (`nieuws`, `filmnieuwstitel`) AGAINST ('$zoekstring') AS score FROM filmnieuws WHERE MATCH (`nieuws`, `filmnieuwstitel`) AGAINST ('$zoekstring')";

Acties:
  • 0 Henk 'm!

  • drm
  • Registratie: Februari 2001
  • Laatst online: 09-06 13:31

drm

f0pc0dert

Dit is misschien handig om even te weten:
A ``word'' is any sequence of characters consisting of letters, digits, `'', and `_'. Any ``word'' that is present in the stopword list or is just too short (3 characters or less) is ignored.
The search for the word MySQL produces no results in the above example, because that word is present in more than half the rows. As such, it is effectively treated as a stopword (that is, a word with zero semantic value). This is the most desirable behaviour -- a natural language query should not return every second row from a 1 GB table.

A word that matches half of rows in a table is less likely to locate relevant documents. In fact, it will most likely find plenty of irrelevant documents. We all know this happens far too often when we are trying to find something on the Internet with a search engine. It is with this reasoning that such rows have been assigned a low semantic value in this particular dataset.
1st user comment:
Note: you should add at least 3 rows to the table
before you try to match anything, and what you're
searching for should only be contained in one of
the three rows. This is because of the 50%
thereshold. If you insert only one row, then now
matter what you search for, it is in 50% or more
of the rows in the table, and therefore
disregarded.

Music is the pleasure the human mind experiences from counting without being aware that it is counting
~ Gottfried Leibniz


Acties:
  • 0 Henk 'm!

  • kvdveer
  • Registratie: November 2000
  • Laatst online: 07-11-2023

kvdveer

Z.O.Z.

Kun je iets minder vaag zijn dan 'het werkt niet' ?

Localhost, sweet localhost


Acties:
  • 0 Henk 'm!

  • Liqued
  • Registratie: Februari 2001
  • Laatst online: 06-08 15:21
The search for the word MySQL produces no results in the above example, because that word is present in more than half the rows. As such, it is effectively treated as a stopword (that is, a word with zero semantic value). This is the most desirable behaviour -- a natural language query should not return every second row from a 1 GB table.

A word that matches half of rows in a table is less likely to locate relevant documents. In fact, it will most likely find plenty of irrelevant documents. We all know this happens far too often when we are trying to find something on the Internet with a search engine. It is with this reasoning that such rows have been assigned a low semantic value in this particular dataset.
Ik had dit al gelezen, maar ik had me toen niet gerealiseerd dat ik maar 2 rijen in mijn tabel had zitten :*)

Acties:
  • 0 Henk 'm!

Verwijderd

Ik heb onlangs voor spelletjesgarnaal een search machine gamaakt voor de volledige site, en ik heb ondervonden dat het meestal het makkelijkst is van gewoon de wildcard '%' te gebruiken:

vb:

SELECT * FROM db WHERE titel = '%zoekstring%'
...

Acties:
  • 0 Henk 'm!

  • zeroxcool
  • Registratie: Januari 2001
  • Laatst online: 04-09 19:14
Heel leuk, op titel zoeken. Maar het doel van FULLTEXT is dat je vaak in posts zelf wilt zoeken.

zeroxcool.net - curity.eu


Acties:
  • 0 Henk 'm!

  • drm
  • Registratie: Februari 2001
  • Laatst online: 09-06 13:31

drm

f0pc0dert

ZeRoXcOoL:
Heel leuk, op titel zoeken. Maar het doel van FULLTEXT is dat je vaak in posts zelf wilt zoeken.
Wat belangrijker is: je krijgt met FULLTEXT een relevantiewaarde die met een LIKE search heel lastig te bepalen is.

Music is the pleasure the human mind experiences from counting without being aware that it is counting
~ Gottfried Leibniz


Acties:
  • 0 Henk 'm!

Verwijderd

wat is het probleem dan ? pas het dan gewoon toe op col body of whateva ge het noemt eh !

SELECT * FROM db WHERE body = '%zoekstring%'
SELECT * FROM db WHERE post = '%zoekstring%'
SELECT * FROM db WHERE <insert own stuff here> = '%zoekstring%'
...

Het was gewoon maar iets dak zei om proberen te helpen ... dit was simpele manier van werken ! Maar idd soms is die FULLTEXT beter !!!

[ Voor 36% gewijzigd door Verwijderd op 08-08-2003 10:57 ]


Acties:
  • 0 Henk 'm!

  • zeroxcool
  • Registratie: Januari 2001
  • Laatst online: 04-09 19:14
drm schreef op 08 August 2003 @ 10:48:
[...]
Wat belangrijker is: je krijgt met FULLTEXT een relevantiewaarde die met een LIKE search heel lastig te bepalen is.
offtopic:
Is fulltext trouwens langzamer dan een eigen gemaakt search engine, met een words tabel en een wordid, postid tabel?

[ Voor 8% gewijzigd door zeroxcool op 08-08-2003 11:01 ]

zeroxcool.net - curity.eu

Pagina: 1