[SQL/PHP] Full text search

Pagina: 1
Acties:

Onderwerpen


Acties:
  • 0 Henk 'm!

Verwijderd

Topicstarter
Ik heb voor de zekerheid ff de search van het forum overlopen en ik kan niks relevants vinden. Dus dan maar posten:

Ik zit wat te prutsen met full text search en ik kom wat problemen tegen.

Als ik dit gebruik:

PHP:
1
2
3
4
SELECT fid, name, year, genre, MATCH (name,summary)
AGAINST ('$opdracht') AS score FROM films
WHERE MATCH (name,summary) AGAINST ('$opdracht' IN BOOLEAN MODE)
HAVING score > 0.2 ORDER by score desc

krijg ik relevante scores, maar kan ik geen boolean operators gebruiken.

Gebruik ik dit:

PHP:
1
2
3
4
SELECT fid, name, year, genre, MATCH (name,summary)
AGAINST ('$opdracht' IN BOOLEAN MODE) AS score FROM films
WHERE MATCH (name,summary) AGAINST ('$opdracht' IN BOOLEAN MODE)
HAVING score > 0.2 ORDER by score desc

dan is het net omgekeerd: boolean operators, maar geen relevante scores.

Ik weet dat er andere manieren bestaan via indexing en noiseword lists (wat waarschijnlijk ook sneller zal gaan), maar ik begrijp niet dat het niet via full text search kan lukken.

Any ideas?

Acties:
  • 0 Henk 'm!

  • curry684
  • Registratie: Juni 2000
  • Laatst online: 06-09 00:37

curry684

left part of the evil twins

En welke SQL database gebruik je?

Professionele website nodig?


Acties:
  • 0 Henk 'm!

  • Bosmonster
  • Registratie: Juni 2001
  • Laatst online: 10-09 08:45

Bosmonster

*zucht*

http://www.mysql.com/doc/en/Fulltext_Search.html
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.

Acties:
  • 0 Henk 'm!

Verwijderd

Topicstarter
Ik gebruik 4.0.13

Ik heb de info op de mysql site overlopen, o.a. ook wat je quote, maar dat werkt niet.

[ Voor 3% gewijzigd door Verwijderd op 15-06-2003 12:17 ]


Acties:
  • 0 Henk 'm!

  • Alex
  • Registratie: Juli 2001
  • Laatst online: 20-08 21:38
Waarom wil je perce dat IN BOOLEAN MODE gebruiken? Je kunt ook makelijk zonder! Probeer hem maar eens uit te voeren en zet er 2 woorden in zonder AND/+ of wat dan ook :).

Deze post is bestemd voor hen die een tegenwoordige tijd kunnen onderscheiden van een toekomstige halfvoorwaardelijke bepaalde subinverte plagiale aanvoegend intentioneel verleden tijd.
- Giphart


Acties:
  • 0 Henk 'm!

Verwijderd

Topicstarter
Ja, maar wildcards (*) zijn toch wel heel erg handig. En de full text search functie is toch daarvoor net gemaakt :/

Acties:
  • 0 Henk 'm!

  • Mister_X
  • Registratie: Februari 2000
  • Laatst online: 17-04 14:07
Hallo, excuses voor de kick, maar ik heb een probleem met de full text search!

ik zit hier al te lezen http://dev.mysql.com/doc/.../en/fulltext-boolean.htm" en weet ook hoe het probleem ontstaat,

namelijk als ik zoek op provincie krijg ik meerder results terug,

AND MATCH (woon_provincie) AGAINST ('Noord-Brabant')

Hij vind uiteraard ook Noord-Holland, en dat moet niet! nu komt dat door de '-' dwz " A leading minus sign indicates that this word must not be present in any of the rows that are returned."

Hoe kan ik nou ervoor zorgen da tie Noord-Brabant als 1 woord ziet... nou gevonden:
'"some words"'

Find rows that contain the exact phrase “some words” (for example, rows that contain “some words of wisdom” but not “some noise words”). Note that the ‘"’ characters that surround the phrase are operator characters that delimit the phrase. They are not the quotes that surround the search string itself.
alleen, sja, als

$SQL = " AND MATCH (woon_provincie) AGAINST ('Noord-Brabant') "
kan ik niet die '" eromheen doen... Noord brabant is een string, en word dan gezien als $search...

Iemand enig idee?

[edit]

heb het zo maar opgelost:
code:
1
2
3
4
5
    if(strpos($value,"-")){
        $q->andDB("$search","'$value'");
    }else{
        $q->textsearchDB(array($search),"'$value'");
    }

:)

[ Voor 30% gewijzigd door Mister_X op 02-11-2005 16:20 ]

Pagina: 1