Re: [PHP] Search thoughts

2008-07-19 Thread Richard Heyes

Mark Kelly wrote:

Hi.

On Saturday 19 July 2008, Richard Heyes wrote:

Currently the site in question uses a very basic LIKE in MySQL, eg
%blah%, but naturally this finds terms such as hjkblahbjkk - which is
not desired. Or such matches should be ranked lower than something that
matches the exact word blah.


I did this with 2 queries, and no need for messing with points etc (unless 
you particularly want to). 

Start with LIKE 'word' query and pull the results into a results array. 
Then do the same query but with LIKE '%word%' and loop through append 
the results to the results array. Use something like if 
(!in_array($thisResult,$resultSet)) while appending to avoid duplicates.


Well no. LIKE is slow and so is in_array(). Admittedly it's not a busy 
site, but still.



How much traffic do you have and what's your hardware? Are your queries 
cached and subsequently repeated? Do you pre cache common queries?


Cheers.

--
Richard Heyes

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search thoughts

2008-07-19 Thread tedd

At 10:47 AM +0100 7/19/08, Richard Heyes wrote:

Hey,

I was hoping to get some ideas on improving a sites search. 
Currently I have two - not a lot but I've been thinking about this 
for a few minutes.


That'll leave a mark. :-)

Currently the site in question uses a very basic LIKE in MySQL, eg 
%blah%, but naturally this finds terms such as hjkblahbjkk - which 
is not desired. Or such matches should be ranked lower than 
something that matches the exact word blah. My thoughts are using a 
points system, eg assigning 5 points for an exact word match, 1 for 
a partial match. And then ordering the search results by the total 
points assigned.


I'm sure that would work, but just how many LIKE items do you want to 
show the user? For me, I would rather not show them anything if there 
is nothing on my site that matches their exact search criteria.


The point being, from my perspective, users don't spend a lot of time 
reading results. They want answers quick and short. I would think 
that if you provided them with a long list of Did you mean this? 
results -- that might frustrate the user.


If I did that, then I would also highlight each LIKE search word to 
show the user why the LIKE results were being presented to them.



Either that or using external search code and not worrying so much.


Considering all, using an external search would probably be better -- 
less time worrying about it and delivering good results to users 
queries is not as simple as it seems. However, if someone could come 
up with a better way, I am sure you could. But, the point is, would 
it make a difference?


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search thoughts

2008-07-19 Thread Richard Heyes
I'm sure that would work, but just how many LIKE items do you want to 
show the user? For me, I would rather not show them anything if there is 
nothing on my site that matches their exact search criteria.


Certainly an idea, but something like We also found... might be 
helpful in regard to typos.


The point being, from my perspective, users don't spend a lot of time 
reading results. They want answers quick and short. I would think that 
if you provided them with a long list of Did you mean this? results -- 
that might frustrate the user.


A good point. For example I rarely go further than the first page on 
Google (I never need to really, but whatever...).


 if someone could come up with a

better way, I am sure you could.


Thanks for the vote of confidence, but I've kept away from search as it 
doesn't overly interest me. In fact that's quite an over statement. It 
really bores the pants off me.


But, the point is, would it make a 
difference?


Well spending some time on it will improve it as it's just the basic 
LIKE at the moment, but point taken - I really don't want to spend a lot 
of time on it.


--
Richard Heyes

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search thoughts

2008-07-19 Thread Mark Kelly
Hi.

Just noticed I replied direct rather than to the list last time, sorry 
about that.

On Saturday 19 July 2008, Richard Heyes wrote:
 How much traffic do you have and what's your hardware? Are your queries
 cached and subsequently repeated? Do you pre cache common queries?

I've done this kind of search twice, but both were for internal web apps so 
I can't link you to them. In both cases I return only items IDs and limit 
it to 10 results, with the subsequent queries being done only if the 
previous ones didn't return enough results to fill the page. Both of these 
speed it up a lot, obviously. One of them has a possible max of 6 
different ways to examine the data tables, and still return a full results 
page in under half a second.

Nothing is pre-cached, and I'm really not sure about the hardware, sorry, 
that's the IT guy's problem. I don't imagine it's anything spectacular 
though.

The apps get quite heavy use but I'm with Tedd on the results issue, we 
only see maybe 10% of the users going to page 2, but these are internal 
users searching company data, so the pattern may not be typical.

Hope you find something you're happy with,

Mark

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search thoughts

2008-07-19 Thread Eric Butera
On Sat, Jul 19, 2008 at 5:47 AM, Richard Heyes [EMAIL PROTECTED] wrote:
 Hey,

 I was hoping to get some ideas on improving a sites search. Currently I have
 two - not a lot but I've been thinking about this for a few minutes.

 Currently the site in question uses a very basic LIKE in MySQL, eg %blah%,
 but naturally this finds terms such as hjkblahbjkk - which is not desired.
 Or such matches should be ranked lower than something that matches the exact
 word blah. My thoughts are using a points system, eg assigning 5 points for
 an exact word match, 1 for a partial match. And then ordering the search
 results by the total points assigned.

 Either that or using external search code and not worrying so much.

 Cheers.

 --
 Richard Heyes

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



Ever play with fulltext search?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search thoughts

2008-07-19 Thread Richard Heyes

Ever play with fulltext search?


Yes, though it's not suitable in this instance.

--
Richard Heyes

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search thoughts

2008-07-19 Thread tedd

At 1:56 PM -0400 7/19/08, Eric Butera wrote:



Ever play with fulltext search?



Never in public. :-)

You could throw all text into your database and then do a fulltext 
search to give back the related pages -- that would work. I think I 
saw that as an example in one of the books I read. PHP Cookbook shows 
an example of the entire King James Bible in a dB -- interesting read 
and demo.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search thoughts

2008-07-19 Thread Eric Butera
On Sat, Jul 19, 2008 at 3:40 PM, tedd [EMAIL PROTECTED] wrote:
 At 1:56 PM -0400 7/19/08, Eric Butera wrote:


 Ever play with fulltext search?


 Never in public. :-)

 You could throw all text into your database and then do a fulltext search to
 give back the related pages -- that would work. I think I saw that as an
 example in one of the books I read. PHP Cookbook shows an example of the
 entire King James Bible in a dB -- interesting read and demo.

 Cheers,

 tedd

 --
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



Yea I've done a lot of compiling content and then searching against
what it is supposed to be.  Fulltext works really well for things like
that.

I've been playing around with the zend search lucene and it is really
powerful too.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search thoughts

2008-07-19 Thread Richard Heyes

 the entire King James Bible in a dB -- interesting read

That's debateable... :-)

--
Richard Heyes

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search thoughts

2008-07-19 Thread Richard Heyes

Hi,


I've been playing around with the zend search lucene and it is really
powerful too.


Worth looking into?

--
Richard Heyes

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search thoughts

2008-07-19 Thread Eric Butera
On Sat, Jul 19, 2008 at 4:06 PM, Richard Heyes [EMAIL PROTECTED] wrote:
 Hi,

 I've been playing around with the zend search lucene and it is really
 powerful too.

 Worth looking into?

 --
 Richard Heyes

Most definitely.  But with all that power and optional stuff comes
complexity too.  It isn't a five minute attempt to see something
working.  In fact I thought it was a bit harder than it needed to be
getting it working (specifically removing a document/re-adding to
update).

What I've done is get a really basic add/edit/remove  search on
partial content set up.  It is pretty easy to set up a search on a
site with it now.  From there I can move from a timed cron job
re-indexing to actual real time updates on content saving if needed.
Also you can customize what exactly gets stored in the search database
too.  You can specify you want to search on document titles versus
just the whole content.  There is a lot there to play with.

Before this I used either a fulltext, simple LIKE, or an external
program like Swish-e.  I really enjoyed using Swish-e, except it
doesn't support utf-8 which is silly in 2008.

http://framework.zend.com/manual/en/zend.search.lucene.html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Search thoughts

2008-07-19 Thread Richard Heyes

http://framework.zend.com/manual/en/zend.search.lucene.html


Nice one, thanks.

--
Richard Heyes

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php