This is a search plugin for WordPress MU (WPMU) that enables the default search box to search across all WPMU blogs. And as far as I know, this is the first 100% plugin solution that does not require cron jobs, hacking core files, or modifying your search template.
Features
- Site-wide searching from any blog
- Upgrade proof; No core file hacking
- Uses default search box
- Data is built on the fly; no cron job necessary
How It Works
Rather than relying on PHP to build complex queries at run-time, which can slow page processing, The One Search WPMU Plugin uses MySQL views. When new blogs are added, the view is automatically updated. End-user searches are then redirected from the individual blog tables and pointed to the appropriate MySQL views.
To Do
- Create install script (for initial views)
- Add tag and category support
- Add end-user blog search selection (global vs . specific blog)
- Create widget
Compatibility
- WordPress MU 1.3.3 (verified working with directories)
- MySQL 5.01+ (Haven’t tested on MySQL 4)
- Works with most Search Everything Plugin (4.2.1, 4.2.2) options (not required)
Installation
- Upload one-search.php to your WordPress MU plugins directory. (/wp-content/mu-plugins)
- Setup initial views: Go to http://<yoursite>/?new=setup
Download
Download the One Search WPMU Plugin here:
Current version: 0.2.0
Last Updated: March 11, 2008
Trunk tarball: trunk-onesearch.tar.gz
Current stable: onesearch.zip
February 9, 2008 at 07:16
Looks VERY promising, subscribing…
February 9, 2008 at 09:30
@Joe: Let me know when you try it out. I’m open to any suggestions.
February 11, 2008 at 12:53
I gave it a whirl, and when I wen to the /?new=setup url, it just brought me to my default homepage. Am I missing something from the directions?
February 11, 2008 at 17:34
Jim, thanks for trying it out. It should be ready to go.
The purpose, and I admit kind of lame, reason for /?new=setup url is to initialize the database. It doesn’t do anything else.
If you’re not getting an error, it should have created 3 views in your database. Check that they were created and try doing a search.
February 13, 2008 at 06:28
Have problem, because after hitting http:///?new=setup nothing happen, new tables in DB aren’t created.
Another question, how to replace global searching only in specified site (home) not in user blogs?
February 13, 2008 at 21:22
Marcin,
You can force the views to be created by creating a new blog.
I haven’t tried it yet, but you should be able to copy the plugin to the /wp-content/plugins directory. Then activate the plugin for only “home”.
I’ve made a bunch of updates that I hope to upload within the next week. It’ll have a better (working?) setup and will be compatible with MySQL < 5.01.
February 15, 2008 at 11:57
Anyone tried this on MySQL 4.x? AFAIR there’s no supports for views unfortunately…
February 16, 2008 at 01:16
eia: As I mentioned in a previous comment, I have an update coming that works on MySQL 4.x.
February 26, 2008 at 16:40
Is there a way to have a onesearch box just for the main blog and have the search boxes in the sub-blogs work as normal, or is that how this does work already?
February 26, 2008 at 17:05
Installation failed for me as I was on a CPanel host and the user didn’t have privs to create views. I granted the privs and now visiting ?new=setup doesn’t appear to do anything — no more errors, but nothing changes in PHPMyAdmin, and searches are returning errors that the view doesn’t exist. Adding a blog from the admin panel doesn’t seem to create the views either. The plugin returns no search results for any search with error wp_v_posts does not exist. So, right now the plugin isn’t working at all for me.
February 26, 2008 at 17:15
Sorry to postbomb here, but I added a blog from the signup page (not the admin panel, which doesn’t seem to update the views??) and it’s now blowing up with WordPress database error: [The used SELECT statements have a different number of columns] CREATE OR REPLACE VIEW `wp_v_comments` followed by a giant expression that I’ll omit for brevity.
March 1, 2008 at 12:35
hello
i have mysql5
i tryed to install your plugin but it doesn’t work
2 view have been created : wp_v_comments and wp_v_postmeta
when i want to delete i have this message
#1356 - View ‘annoncesnesex.wp_v_comments’ references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
could you help me?
March 1, 2008 at 13:00
i have delete view successfuly
i think that the plugin didn’t work for me because when a new blog is create the wp_v_posts is not create…
so search give 0 result
i have doing an echo of the v_post_select_query and it give me this
(SELECT ‘1′ AS blog_id, ‘1′ AS site_id, ‘mysite.fr’ AS domain, ‘/’ AS path, posts1.* FROM wp_1_posts posts1) (SELECT ‘12′ AS blog_id, ‘1′ AS site_id, ‘mysite.fr’ AS domain, ‘/tototo/’ AS path, posts12.* FROM wp_12_posts posts12) (SELECT ‘13′ AS blog_id, ‘1′ AS site_id, ‘mysite.fr’ AS domain, ‘/test/’ AS path, posts13.* FROM wp_13_posts posts13) (SELECT ‘13′ AS blog_id, ‘1′ AS site_id, ‘mysite.fr’ AS domain, ‘/test/’ AS path, posts13.* FROM wp_13_posts posts13)
maybe the error is in FROM wp_13_posts posts13 ??
thanks for help
March 1, 2008 at 13:50
its me again
that run ! the version you have upload seems to be incorrect
i have change this :
$i = 0;
$v_query = ”;
foreach ($blogs as $blog) {
if ($i != 0) {
$v_select_query .= ‘ UNION ‘;
$v_postmeta_select_query .= ‘ UNION ‘;
$v_comments_select_query .= ‘ UNION ‘;
}
$v_post_select_query .= ” (SELECT ‘{$blog->blog_id}’ AS blog_id, ‘{$blog->site_id}’ AS site_id, ‘{$blog->domain}’ AS domain, ‘{$blog->path}’ AS path, posts{$blog->blog_id}.* FROM wp_{$blog->blog_id}_posts posts{$blog->blog_id}) “;
$v_postmeta_select_query .= ” (SELECT ‘{$blog->blog_id}’ AS blog_id, ‘{$blog->site_id}’ AS site_id, ‘{$blog->domain}’ AS domain, ‘{$blog->path}’ AS path, postmeta{$blog->blog_id}.* FROM wp_{$blog->blog_id}_postmeta postmeta{$blog->blog_id}) “;
$v_comments_select_query .= ” (SELECT ‘{$blog->blog_id}’ AS blog_id, ‘{$blog->site_id}’ AS site_id, ‘{$blog->domain}’ AS domain, ‘{$blog->path}’ AS path, comments{$blog->blog_id}.* FROM wp_{$blog->blog_id}_comments comments{$blog->blog_id}) “;
$i++;
}
by this :
$i = 0;
$v_query = ”;
foreach ($blogs as $blog) {
if ($i != 0) {
$v_post_select_query .= ‘ UNION ‘;
$v_postmeta_select_query .= ‘ UNION ‘;
$v_comments_select_query .= ‘ UNION ‘;
}
$v_post_select_query .= ” (SELECT ‘{$blog->blog_id}’ AS blog_id, ‘{$blog->site_id}’ AS site_id, ‘{$blog->domain}’ AS domain, ‘{$blog->path}’ AS path, wp_{$blog->blog_id}_posts.* FROM wp_{$blog->blog_id}_posts) “;
$v_postmeta_select_query .= ” (SELECT ‘{$blog->blog_id}’ AS blog_id, ‘{$blog->site_id}’ AS site_id, ‘{$blog->domain}’ AS domain, ‘{$blog->path}’ AS path, wp_{$blog->blog_id}_postmeta.* FROM wp_{$blog->blog_id}_postmeta) “;
$v_comments_select_query .= ” (SELECT ‘{$blog->blog_id}’ AS blog_id, ‘{$blog->site_id}’ AS site_id, ‘{$blog->domain}’ AS domain, ‘{$blog->path}’ AS path, wp_{$blog->blog_id}_comments.* FROM wp_{$blog->blog_id}_comments) “;
$i++;
}
and it’s working fine the problem was that $v_query doesn’t exist and some variable problem like this for example comments{$blog->blog_id}.* FROM wp_{$blog->blog_id}_comments comments{$blog->blog_id}
sorry for my english i’m french
good file can be upload here http://informatique-rodez.fr/one_search_new.zip
March 1, 2008 at 16:19
emile: Thanks for catching that. I’ve made that update.
March 2, 2008 at 03:01
no problem thanks for you job
i’m interessted by the search function of your site who display the result in live in the sidebar
could you send me a message to explain me how to do??
thanks
March 2, 2008 at 14:53
emile: I’m using Addicted to Live Search. It’s plug-n-play as long as you use the default search box name.
March 10, 2008 at 04:37
Hi
I can’t get this plugin to work, and when installed and activated, it stops Search Everything (v4.2.2) working. There are no specific errors returned, just no search results. I’m running Apache/2.2.4 (Win32), php5.2.5, MySQL 5. I’m using directories as opposed to sub domains. Not a lot to go on I know, but any ideas ?
Thanks.
March 10, 2008 at 04:45
do you have try this ?
http://informatique-rodez.fr/one_search_new.zip
for me it’s working
March 10, 2008 at 06:08
Thanks Emile, but yes, tried that, and it still doesn’t work. I am using search everything 4.2.2, so maybe that is the issue, but I’m at a loss at the moment.
March 10, 2008 at 07:42
Still trying to get to the bottom of this. Is it right that the one search plugin isn’t available through the Plugin Management screen when it’s in the wp-content/mu-plugins directory? My other plugins are located in wp-content/plugins (which is where I first of all put one_search.php and then activated it).
March 10, 2008 at 07:43
Simon, Do you have a link? Let me know what kind of error(s) you’re receiving. I’ll try Search Everything (SE) 4.2.2 and see how things go.
Also, which SE options are you using? If you haven’t already, try enabling only posts and pages.
March 10, 2008 at 07:45
Simon, There is no admin screen (yet).
March 10, 2008 at 08:00
My install is on internal development server unfortunately. Had tags, approved comments, excerps, attachments and custom fields enabled. Just tried unchecking all but pages, but no change.
My apache errors log says
“WordPress database error: [Table 'lf_cms.wp_v_posts' doesn't exist]\n SELECT DISTINCT SQL_CALC_FOUND_ROWS wp_v_posts.* FROM wp_v_posts WHERE 1=1 AND (((post_title LIKE '%commercial%') OR (post_content LIKE '%commercial%')) AND ((post_title LIKE '%terms%') OR (post_content LIKE '%terms%')) OR (post_title LIKE '%commercial terms%') OR (post_content LIKE '%commercial terms%')) AND (post_status = 'publish' OR post_status = 'private') ORDER BY post_date DESC LIMIT 0, 10\n, referer: http://cms.domain.co.uk/sites/
March 10, 2008 at 08:06
The error shows that the view wasn’t created. Try creating a new blog (this will create/update the view) and let us know how it goes.
March 10, 2008 at 08:15
Created a new blog, (through the admin interface) but still get the same error?
April 16, 2008 at 15:51
This plugin works a treat, but my problem is it doesn’t include data from every post ever made. So I’m only getting results from the most recent blog postings across my site, which is nice and all….but I need a complete site search solution.
April 21, 2008 at 21:36
In the version function of MySQL, the return value is a character string.
Your source code cannot make the view because it compares the return value with the
integer.
if ($mysqlversion >= 5.01 )
ććā if ($mysqlversion >= “5.0.1″ )
sorry for my english iām japanese
May 9, 2008 at 14:25
This works for me; however, it was a little confusing at first, because, as someone pointed out, it does not seem to work for previous posts and pages, but only for newer ones that have been created after this plug-in is installed. Which is fine, because my site is just being built, but this caused some initial confusion while I was trying to install it…install..test..nothing..test again…nothing. Then I read the post suleiman wrote, that only new posts were showing up in searches. So I create a new post and VIOLA! there it is.
I also tried using this plugin in individual blogs on my site by putting it into the plugins folder and activating it in the Plugins panel. It worked but only for pages, and not for posts. I tried different settings with Searcheverthing, but it only seems to like pages in that setup. So I just deactivated and installed in mu-plugins and started over again with my posts and pages so everything from here on out should work.
May 14, 2008 at 08:35
A little side note: I was starting over with a complete re-install of WPMU, created all of my blogs, and installed the onesearch plugin..but it was only searching my main blog. I went into Site-Admin>blogs>edit each blog and set my new blogs to public (Der!). Now this plugin works perfectly. Thanks.
June 11, 2008 at 12:18
OK, I’ve installed the plugin in the plugins folder (since I just wanted to enable it for the main website) and I went to the URL to setup the views and created a new blog “just in case” to make sure and a new post and tried searching from the home page but when I search for pages that exist in the other blog I don’t get any search results. I then wondered if it was because I had set it up in the plugins folder so I moved it over to the mu-plugins folder and got the same result.
Is there anything I missed?
June 30, 2008 at 09:36
I am getting the same result as Omar.