Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

search result like Google

Quote Reply
search result like Google
Is there a way that the search result return the result like Google, that the description display the word that was search, and it return just the sections that contain this word
Quote Reply
Re: [nir] search result like Google In reply to
Mmm, not easily (especially if they are using more than one word to search for)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] search result like Google In reply to
The option to highlighting the words that was searching is already exist, maybe it possible to use this.
Quote Reply
Re: [nir] search result like Google In reply to
All that does, is a simple regex to find the word, and match highlight it (using a simple <font>)

To do what you want, it would have to do more complex stuff - like finding the word first, and then adding say 5 words before/after the keyword - and then add some ...) . Sounds simple - but its not particually easy :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [nir] search result like Google In reply to
nir wrote:
Is there a way that the search result return the result like Google, that the description display the word that was search, and it return just the sections that contain this word

The first thing that jumped into my mind was a regex that would match n-words/keyword/n-words ... but not being especially handy with that (where's paul when you need him?), I went looking. And looking. And looking. I found some really, really convoluted ideas, which made me start to doubt my original idea that it could be a simple regex, then realized they were all on php forums ;)

I found a couple of potential CPAN modules,
http://search.cpan.org/.../lib/Text/Context.pm
http://search.cpan.org/...rch/Tools/HiLiter.pm

But they were not exactly what people are asking for, and were kind of klunky for such an apparantly simple job.

Also this "Context Grep" idea (searches on that didn't reveal more, unfortunately)
http://www.pre-emptive.net/doco/context-grep-perl

And then this article on StackOverflow, that is pretty much close to what had jumped into my head, but the code is unfinished.
http://stackoverflow.com/...n-the-search-results
Code:
if ($text =~ /((\S+\s+){0,4})($search)((\s+\S+){0,4})/i) {
my ($pre, $match, $post) = ($1, $3, $4);
...
}
There is a working example, but they point out with the /i tag it's slow. There are a few suggestions on how to improve it, using @+ & @- , but no code to go with it.
Quote:
...to suggest using @+ and @- to avoid the performance penalty imposed by $ and #' -

Maybe someone can use that page as a starting point for a piece of finished code?


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] search result like Google In reply to
I don't know if this is a related query but I find that the built-in user side search requires exact search terms whereas the admin side search is a little more forgiving.

For example, if I have a product called First ABC-123 it won't show in the results if a user types ABC123 but it will if they type ABC-123. Google search results on the other hand do account for this and will return results for both on a single query.

I have a lot of searches in the log that show 0 results, even though a product is listed, simply because the search term wasn't exact.
Quote Reply
Re: [MJB] search result like Google In reply to
One possible solution for that, is to add a new field - and then make that contain the possible "mis-spellings" of the title etc ... thats what I've done before Smile

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] search result like Google In reply to
So how would you implement this?

Do you add a new table for alternative spellings?

Does the field data have to be embedded / displayed in the html pages or will the search just look through the database table?
Quote Reply
Re: [MJB] search result like Google In reply to
Just add it via Links > Properties > Add Column .. .something like:

Title_Alternative CHAR(255)

Depending on how your search is setup, it should just find them automatically :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] search result like Google In reply to
Is there any way to auto-populate this field (I'm guessing not). I have over 3,300 links so there's no way that I'm going through all of them manually. Shocked
Quote Reply
Re: [MJB] search result like Google In reply to
Hi,

Is it just a case of removing the - from the titles? Just to get you started? If so, its a piece of cake with a few SQL queries :)

Quote:
UPDATE glinks_Links SET Title_Alternative = Title;

...and then:

Quote:
UPDATE glinks_Links SET Title_Alternative = REPLACE(Title_Alternative,"-","");

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] search result like Google In reply to
Wow, that's much better. Smile
Quote Reply
Re: [MJB] search result like Google In reply to
MJB wrote:
Wow, that's much better. Smile

Good to hear Cool
Quote Reply
Re: [Andy] search result like Google In reply to
So, if I want to add other alternatives to that field do I just separate then with a comma or a space?

Code:
ABC-123,ABC123,ABC 123

or

Code:
ABC-123 ABC123 ABC 123

or something else?
Quote Reply
Re: [MJB] search result like Google In reply to
I would imagine ", " seperated would be your best option (otherwise the search code may start brining up weird results)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] search result like Google In reply to
Hi,

I wanted to put it in a thread of its own but I think it makes sense to point you to the new thread:
http://www.gossamer-threads.com/.../?page=unread#unread

Regards

Niko