|
|
Source code |
1 |
SELECT * FROM datenbank WHERE suchfeld1 LIKE '%Hier%' AND suchfeld1 LIKE '%mein%' AND suchfeld1 LIKE '%Suchbegriff%' |
|
|
Source code |
1 |
SELECT * FROM datenbank WHERE suchfeld1 LIKE '%Hier%' OR suchfeld1 LIKE '%mein%' OR suchfeld1 LIKE '%Suchbegriff%' |
Quoted
It should be noted in the documentation that IN BOOLEAN MODE will almost always return a relevance of 1.0. In order to get a relevance that is meaningful, you'll need to:
SELECT MATCH('Content') AGAINST ('keyword1 keyword2') as Relevance FROM table WHERE MATCH ('Content') AGAINST('+keyword1 +keyword2' IN BOOLEAN MODE) HAVING Relevance > 0.2 ORDER BY Relevance DESC
Notice that you are doing a regular relevance query to obtain relevance factors combined with a WHERE clause that uses BOOLEAN MODE. The BOOLEAN MODE gives you the subset that fulfills the requirements of the BOOLEAN search, the relevance query fulfills the relevance factor, and the HAVING clause (in this case) ensures that the document is relevant to the search (i.e. documents that score less than 0.2 are considered irrelevant). This also allows you to order by relevance.
This may or may not be a bug in the way that IN BOOLEAN MODE operates, although the comments I've read on the mailing list suggest that IN BOOLEAN MODE's relevance ranking is not very complicated, thus lending itself poorly for actually providing relevant documents. BTW - I didn't notice a performance loss for doing this, since it appears MySQL only performs the FULLTEXT search once, even though the two MATCH clauses are different. Use EXPLAIN to prove this.
|
|
PHP Quellcode |
1 |
SELECT MATCH('".$this->suchbegriff."') AGAINST ('name beschreibung thema region') as Relevance FROM clique WHERE MATCH ('".$this->suchbegriff."') AGAINST('+name +beschreibung +thema +region' IN BOOLEAN MODE) HAVING Relevance > 0.2 ORDER BY Relevance DESC |
|
|
Source code |
1 2 3 |
Invalid SQL: SELECT MATCH('gnex') AGAINST ('name beschreibung thema region') as Relevance FROM clique WHERE MATCH ('gnex') AGAINST('+name +beschreibung +thema +region' IN BOOLEAN MODE) HAVING Relevance > 0.2 ORDER BY Relevance DESC
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''gnex') AGAINST ('name beschreibung thema region') as Relevance FROM clique WHER' at line 1
|
|
|
Source code |
1 2 3 4 |
ALTER TABLE clique ADD FULLTEXT KEY name (name); ALTER TABLE clique ADD FULLTEXT KEY beschreibung (beschreibung); ALTER TABLE clique ADD FULLTEXT KEY thema (thema); ALTER TABLE clique ADD FULLTEXT KEY region (region); |
|
|
SQL Code |
1 |
SELECT tabellenspalten FROM tabelle WHERE x=y AND a=b ORDER BY XYZ DESC |
|
|
SQL Code |
1 |
SELECT MATCH('".$this->suchbegriff."') AGAINST ('name beschreibung thema region') AS Relevance |
|
|
SQL Code |
1 |
SELECT tabellenspalte AS `Relevance` FROM clique WHERE MATCH ('".$suchbegriff."') AGAINST('+name +beschreibung +thema +region' IN BOOLEAN MODE) HAVING Relevance > 0.2 ORDER BY Relevance DESC |
This post has been edited 1 times, last edit by "Snowflake" (Mar 16th 2009, 1:16am)
|
|
Source code |
1 |
$sql = "SELECT * FROM clique WHERE MATCH (name,beschreibung,thema,region) AGAINST ('".$this->suchbegriff."' IN BOOLEAN MODE)";
|
|
|
PHP Quellcode |
1 |
$sql = "SELECT * FROM clique WHERE ID IN ('".$IDs."') ORDER BY time DESC"; |
|
|
PHP Quellcode |
1 |
$IDs = '2,3'; |
|
|
PHP Quellcode |
1 2 3 |
$sqlCount = "SELECT COUNT(*) AS count FROM clique WHERE ID IN ('".$IDs."')"; $rowCount = WCF::getDB()->getFirstRow($sqlCount); $this->items = $rowCount['count']; |
This post has been edited 2 times, last edit by "Gnex" (Mar 16th 2009, 4:22pm)
|
|
PHP Quellcode |
1 |
$sql = "SELECT * FROM clique WHERE ID IN ('".$IDs."') ORDER BY time DESC"; |
|
|
PHP Quellcode |
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 31 32 33 34 35 36 37 38 39 40 41 42 |
$sqlSearch = "SELECT searchData FROM gx_search WHERE searchID = ".$this->cn." AND userID = ".WCF::getUser()->userID." AND searchType = 'clique'"; $search = WCF::getDB()->getFirstRow($sqlSearch); if (!isset($search['searchData'])) { require_once(WCF_DIR.'lib/system/exception/IllegalLinkException.class.php'); throw new IllegalLinkException(); } $IDs = implode(',', unserialize($search['searchData'])); ### Page-Aufteilung Anfang $sqlCount = "SELECT COUNT(*) AS count FROM clique WHERE ID IN ('".$IDs."')"; $rowCount = WCF::getDB()->getFirstRow($sqlCount); $this->items = $rowCount['count']; if (isset($_REQUEST['pageNo'])) { $this->pageNo = $_GET['pageNo']; } else { $this->pageNo = '1'; } $this->itemsPerPage = THREAD_POSTS_PER_PAGE; $this->pages = intval(ceil($this->items / $this->itemsPerPage)); if ($this->pageNo > $this->pages) $this->pageNo = $this->pages; if ($this->pageNo < 1) $this->pageNo = 1; $this->startIndex = ($this->pageNo - 1) * $this->itemsPerPage; $this->endIndex = $this->startIndex + $this->itemsPerPage; $this->startIndex++; if ($this->endIndex > $this->items) $this->endIndex = $this->items; WCF::getTPL()->assign('pageNo', $this->pageNo); WCF::getTPL()->assign('pages', $this->pages); ### Page-Aufteilung Ende $sql = "SELECT * FROM clique WHERE ID IN ('".$IDs."') ORDER BY time DESC"; $result = WCF::getDB()->sendQuery($sql, $this->itemsPerPage, ($this->pageNo - 1) * $this->itemsPerPage); while ($row = WBBCore::getDB()->fetchArray($result)) { $cliqueUebersicht = new CliqueUebersicht($row['ID']); $cliqueUebersicht->handleData($row); $this->inhaltSearch[] = $cliqueUebersicht; } |
|
|
Source code |
1 |
a:2:{i:0;s:1:"2";i:1;s:1:"3";}
|
|
|
PHP Quellcode |
1 |
$IDs = implode(',', unserialize($search['searchData'])); |
|
|
SQL Code |
1 |
SELECT * FROM clique WHERE ID IN ('".$IDs."') ORDER BY time DESC" |
|
|
SQL Code |
1 |
SELECT COUNT(*) AS count FROM clique WHERE ID IN ('".$IDs."') |
|
|
SQL Code |
1 2 |
SELECT COUNT(*) AS count FROM clique WHERE ID IN (1,2) SELECT COUNT(*) AS count FROM clique WHERE ID IN ('1,2') |
|
|
SQL Code |
1 |
SELECT COUNT(*) AS count FROM clique WHERE ID IN (1,2) |
![]()
SQL Code
1 SELECT COUNT(*) AS count FROM clique WHERE ID IN ('".$IDs."')
[..]Ich habe mir den Wert ausgegen lassen und siehe da, er gibt 1 aus
![]()
SQL Code
1 SELECT COUNT(*) AS count FROM clique WHERE ID IN (1,2)
Hab ich geändert, leider immer noch der selbe Fehler.
in phpMyAdmin zählt er zwei Einträge, also richtig.
|
|
PHP Quellcode |
1 2 3 4 5 6 |
class FooPage extends AbstractPage() { function show() { $rowCount = WCF::getDB()->getFirstRow("SELECT COUNT(*) AS count FROM clique WHERE ID IN (1,2)"); echo $rowCount['count']; } } |
Nebenbei habe ich auch noch ein wenig getestet: Eine "normale" Suche mit LIKE ist im gegensatz zu Fulltext ca. 1,145 ms langsamer. Dafür verursacht die Fulltext-Suche ein ganz bisschen mehr Auslastung (ca. 0,000345%).
Vielleicht hilft es irgendwann mal.