Jump to content

adding a site search


wrathican

Recommended Posts

Heya people

 

Im trying to add a search function to my website. ive got a few ideas, but not sure on how to implement one or two.

 

The simplest way is obviously going to be to use the mysql like clause.

with this i have two options:

1: search for full search term and return all results that contain the exact phrase.

2: explode the search term and use multiple like clauses and return all results that contain any of the derrived terms.

 

This seems to be unhealthy for a few reasons.

1: a user could search for 'the' and each entry containging the word 'the' would be returned.

2: a user could use keywords and search for something like 'loop php'. so wither all results containing the phrase 'loop in php' or 'loop' or 'php' or 'in' would be returned using the above two methods.

 

this could get messy and not very reliable.

 

i had another idea:

remove any words that are not keywords, eg: 'a', 'and', 'the', 'a'... etc

this could be done with a simple preg_replace, but i see the 'bad' words array being pretty huge.

then search using multiple like queries.

 

are there better ways?

would any of these be efficient?

 

Thanks for your help in advance.

 

Wrath

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.