Hi,
For my blog the current search / quicksearch (or livesearch) is kind of useless, since it does not automatically connect the search terms with and AND. So a search for more than one blog related keyword leads to several dozen of results, instead of a more specific result.
Furthermore the search does only cover the entry body and extended (and maybe tags, but not the extended properties.
I don't really get how the plugin works (neither search in general nor the livesearch). Could someone please give me a hint how to fix those issues? Maybe also as options in the backend.
Daniel
Quicksearch (AND and extended properties)
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Quicksearch (AND and extended properties)
Hi!
The search uses mysql fulltext search, so you can use "+word1 +word2" to have an AND combination.
HTH,
Garvin
The search uses mysql fulltext search, so you can use "+word1 +word2" to have an AND combination.
HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: Quicksearch (AND and extended properties)
And where would I change that default behavior? I think my visitors may not know that they could use a '+'. Furthermore I would love to search the custom extended fields as well, since I have some important keywords there.
Daniel
Daniel
-
kleinerChemiker
- Regular
- Posts: 765
- Joined: Tue Oct 17, 2006 2:36 pm
- Location: Vienna/Austria
- Contact:
Re: Quicksearch (AND and extended properties)
Allthough MySQL doesnt use AND, articles with all of the search words should come first in the list because MySQL does a ranking of the results.
Re: Quicksearch (AND and extended properties)
Ok, but that does not solve the problem.
I see in the stats, that the visitors aren't using '+' and even though the results may be sorted it is still a mess: example from my blog: you look for 'supply chain agility' where I wrote about 3 or 4 articles about you still get about 120 results since in about every article there's one of these keywords.
To mitigate this I already have written a plugin which adds a '+' in front of every search term, but this only works for the final search results not for the livesearch results.
And even if that would work the search does not seem to include the text within the custom fields, which for my articles contain important information.
Where should I have a look within the code for these issues?
Daniel
I see in the stats, that the visitors aren't using '+' and even though the results may be sorted it is still a mess: example from my blog: you look for 'supply chain agility' where I wrote about 3 or 4 articles about you still get about 120 results since in about every article there's one of these keywords.
To mitigate this I already have written a plugin which adds a '+' in front of every search term, but this only works for the final search results not for the livesearch results.
And even if that would work the search does not seem to include the text within the custom fields, which for my articles contain important information.
Where should I have a look within the code for these issues?
Daniel
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Quicksearch (AND and extended properties)
Hi!
You can write a HTML nugget with text containing help for your visitors on how to search?
Extending the search for custom entryproperties can easily be done with a plugin, there's a hook for the entry search. Check for example the staticpage plugin, this performs additional searches for static pages, you can use that to search for your custom content if you like...
How do you do this? To replace this you should either replace $_REQUEST['s'] (livesearch) / $serendipity['GET']['searchTerm'] (quicksearch) in the frontend_config hook, or hook on "frontend_fetchentries" to replace $eventData on the actual SQL code, which is executed in the serendipity_searchEntries() function.
HTH,
Garvin
You can write a HTML nugget with text containing help for your visitors on how to search?
Extending the search for custom entryproperties can easily be done with a plugin, there's a hook for the entry search. Check for example the staticpage plugin, this performs additional searches for static pages, you can use that to search for your custom content if you like...
Code: Select all
To mitigate this I already have written a plugin which adds a '+' in front of every search term, but this only works for the final search results not for the livesearch results.HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: Quicksearch (AND and extended properties)
Ok, thanks, I'll have a look into the static page plugin.
That's the code I am using to add the plusses. Furthermore I changed some code so that the +'es are not displayed on the results page. Is there a better way to do that.
The disadvantage of this code is that the results one gets from the "live search" (the javascript which opens when you start typing) are different then those from the final results. And I would love to align them.
Daniel
That's the code I am using to add the plusses. Furthermore I changed some code so that the +'es are not displayed on the results page. Is there a better way to do that.
The disadvantage of this code is that the results one gets from the "live search" (the javascript which opens when you start typing) are different then those from the final results. And I would love to align them.
Daniel
Code: Select all
function event_hook($event, &$bag, &$eventData) {
global $serendipity;
$hooks = &$bag->get('event_hooks');
if (isset($hooks[$event])) {
switch($event) {
case 'frontend_configure':
if (isset($serendipity['GET']['searchTerm'])) {
$position = strpos($serendipity['GET']['searchTerm'],"+");
if ($position === false) {
$serendipity['GET']['searchTerm'] = str_replace(" ", " +", "+" . $serendipity['GET']['searchTerm']);
}
}
return true;
break;
default:
return false;
}
} else {
return false;
}
}-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Quicksearch (AND and extended properties)
Hi!
You did read my posting about $_REQUEST['s']?
Regards,
Garvin
You did read my posting about $_REQUEST['s']?
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: Quicksearch (AND and extended properties)
Indeed I did, but I did not understand it, now I had a look at the s9y_event_livesearch code, but I still don't know how I would catch which event to change $_REQUEST['s']...
Daniel
ps. I also read your proposal to put an html nugget somewhere explaining the plus-thing... but I don't think that would be a good solution for two reasons 1) I then had additional non-important text on my page where I don't want it (it should be self explanatory) 2) I like to limit the search results to as few as possible.
Daniel
ps. I also read your proposal to put an html nugget somewhere explaining the plus-thing... but I don't think that would be a good solution for two reasons 1) I then had additional non-important text on my page where I don't want it (it should be self explanatory) 2) I like to limit the search results to as few as possible.
-
garvinhicking
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Quicksearch (AND and extended properties)
Hi!
The same event like you currently rewrite $serendipit['GET']['searchTerm’]. You should be able to do the same, by simpy copy&paste and do it with $_REQUEST's'....
Regards,
Garvin
The same event like you currently rewrite $serendipit['GET']['searchTerm’]. You should be able to do the same, by simpy copy&paste and do it with $_REQUEST's'....
What would you suggest?ps. I also read your proposal to put an html nugget somewhere explaining the plus-thing... but I don't think that would be a good solution for two reasons 1) I then had additional non-important text on my page where I don't want it (it should be self explanatory) 2) I like to limit the search results to as few as possible.
Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Re: Quicksearch (AND and extended properties)
That was way easier than expected. I just was not aware of the $_REQUEST variable. I searched a little bit without success, is there some documentation about this?
With this solution the search problem is solved for me. Both live- and quick search now always use '+' as connector.
Of course it would be nice to have this as a general option in the quick / livesearch plugin.
Daniel
ps. I also already included the search within the custom fields.
I posted the code of the plugin here: http://pastebin.com/7YpHamB5
With this solution the search problem is solved for me. Both live- and quick search now always use '+' as connector.
Of course it would be nice to have this as a general option in the quick / livesearch plugin.
Daniel
ps. I also already included the search within the custom fields.
I posted the code of the plugin here: http://pastebin.com/7YpHamB5
Re: Quicksearch (AND and extended properties)
A good example for a search function that I find quite intuitive: http://www.reichelt.de
eg. search for "stiftleiste 2x gerade 2,54" starting first with only the first term and then adding the others. with each iteration the number of results decreases until you find what you want!
If you used the s9y (or) search for that the number of results would increase with each iteration.
I am not familiar with "web search theory", so maybe there is an application for an or-search, but there definitely is an application for and-connected search!
What confuses me is that I seem to be the only one concerned with or using the search this way...
Daniel
eg. search for "stiftleiste 2x gerade 2,54" starting first with only the first term and then adding the others. with each iteration the number of results decreases until you find what you want!
If you used the s9y (or) search for that the number of results would increase with each iteration.
I am not familiar with "web search theory", so maybe there is an application for an or-search, but there definitely is an application for and-connected search!
What confuses me is that I seem to be the only one concerned with or using the search this way...
Daniel