EvilZone

Programming and Scripting => Web Oriented Coding => : Phage August 05, 2012, 10:10:23 PM

: Search engine
: Phage August 05, 2012, 10:10:23 PM
Hmm i know that i have maked a thread on almost the same topic, but it wasn't working for me and i want to start form scratch here.

I'm currently remaking my site and decided to make my own search function (not a third party one). The problem is that the php search engines i have found or used wasn't working. So therefore i'm asking you about how to setup my own php search engine on my website.

I do not know any php so i know this was kind of stupid, but i want to learn, and i'm bussy with learning c++ right now so i do not have the time to learn php at the moment.

So i know that some of you guys probertly are going to say wait until you have learned some php, but i need this right now and as i mentioned i do not have the time to learn php.
: Re: Search engine
: ca0s August 05, 2012, 10:58:31 PM
If it is for your own website, you have two options:
- Maintain a database with the content and search in it.
- Crawl your own website and store results (we had a contest about that, look for it).
I think the first one will be the best for you. If you are already storing your content in a db just do a bunch of SQL queries like
:
SELECT * FROM articles WHERE topic LIKE '%cleanQuery% OR text LIKE '%cleanQuery%'
SELECT * FROM comments WHERE comment LIKE '%cleanQuery' or author LIKE '%cleanQuery%'
Etc.
Edit: I fully read your post. Sorry, I can't give you copy&use code right now. However, this is a really simple task. Spend 2 days learning PHP+SQL basics and you will probably come up with something :)
: Re: Search engine
: Phage August 05, 2012, 11:16:53 PM
Thank you for your reply, the problem is that i do not use any SQL db, because i want to keep it as simple as possible.
: Re: Search engine
: techb August 05, 2012, 11:36:20 PM
Thank you for your reply, the problem is that i do not use any SQL db, because i want to keep it as simple as possible.

Then you could go with the crawl method. Include tags on pages of everything the page/post is about. Match search terms a against all the tags. Regular expressions could come in handy also, for when your comfortable with the language.

For simplicity, make sure to sanitize the input input. Such as making it all lower case,  stripping punctuation, etc. It will make things easier for the searching.
: Re: Search engine
: Stackprotector August 06, 2012, 01:37:14 PM
Thank you for your reply, the problem is that i do not use any SQL db, because i want to keep it as simple as possible.
There are reasons in this world why a DB is invented, BECAUSE IT IS LESS WORK.
: Re: Search engine
: Phage August 06, 2012, 03:08:32 PM
yeah, i'm probertly also going to use the SQL db.