php and mysql search engine

Cyan

GBATemp's lurking knight
OP
Former Staff
Joined
Oct 27, 2002
Messages
23,749
Trophies
4
Age
46
Location
Engine room, learning
XP
15,662
Country
France
I'm posting in my blog this time, because I know I will have no answer, like always with my posts...


Anyway, I'm currently creating my working place's website, and I want to include a search engine.

I have few problems :

1 - When I use the plus "+" in the URL, or even the %2B, it's converted in a space when reading it with $_GET[name] even if not using urldecode(), defeating the "+" purpose of the boolean search.

2 - while sorting the results I would like to prioritize one column over the other one.
Because titles are usually more specific to the subject than other pages containing the searched term.

3 - I would like to create a result page with content preview like google.


------
EDIT on April 4th 2010
------
Result :

1) I set the form to action="post", too bad I couldn't use the GET method like google does.
I'm using URL rewriting, and POST method break my URL layout by showing "index.php?search=gbatemp" instead of /search/gbatemp

2) I don't know yet how to do it.

3) Woot ! I found how to do the result preview ala google.
here is what I'm doing :
- create a database, the "content" column is a copy of the page printable version (without html code inside), only the text.
- do the mysql_query to select all the needed fields, + a columns with the relevancy, and sort the result by relevancy.
- for each result entry, explode all the text in an array of words
- group the array by 20 words and recreate a text portion with it
- search the group if it match the searched terms.
- if the searched terms are present, keep that text part. Look for the next one (3~4 part max). If no part is return (ex. match the title but not the content), select few first content's words.
- process the resulted text to the higlight process.
- print the result.



PHP (4) and Mysql source code for a Search engine with Preview results.
CODE
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    NinStar @ NinStar: nes remix 1 had the bad one, nes remix 2 had the good one