![]() |
[php/mysql]search queries and handling
I'm having some problems implementing my concept of searching on my blog [www.binaryelysium.com].
This is the way I am attempting to run a query. Searcher submits terms ie: "large red clowns." What I want to do is give results in the following order (top with highest priority):
So... for the above example the user would get:
But the last three ordered in such a manner of being most recent. Does anyone have any idea how I could go about doing it? |
You could seperate the search string into words, and then generate a really bigass where clause with ANDs and ORs....
Or, seperate the searches into multiple queries and use mysql's UNION operation to concat the results together. |
When I was writing my first search engine, I thought of doing this. Then I realized that Google only includes results that have all terms. The difference is that they show results that are pages that link to pages that have your search terms. Basically, you don't need to do what you're saying, because you can just construct people to search more generally (less terms).
|
There are really two issues here. Querying matches from the database is one. The other is ranking the responses by (let's call it) keyword density.
The first is easy--just split your query terms on spaces and do an OR query for each of them. Then run a post-query ranking process where you test each record returned from your query for the presence of each of your search terms, and scores them. Then sort your responses by score, and bob's yer uncle. Like this: Code:
//Let's say that array $responses has strings of response values. |
So to do the actual query would you do seperate queries for each term?
PHP Code:
|
egh ugly highlight colors.
Anyways i figured out how to combine all the queries: Code:
$search = explode(" ",$_GET["q"]); |
Quote:
Here is your code with some modifications for my situation: Code:
$search = explode(" ",$_GET["q"]); |
All times are GMT -8. The time now is 03:01 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project