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 2.3.3-2.7 beta rev.1650 (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: Create a new blog from your admin.
Download
Download the One Search WPMU Plugin here:
Current version: 0.4.5
Last Updated: February 9, 2009
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.
July 8, 2008 at 22:42
Hi Jason,
This plugin works like a charm, but I do have several questions and suggestions.
* An ability to select per blog if it will search on its own blog or on in a sitewide manner would be nice.
* How are the results sorted if at all? Is it all posts of each blog being picked up one after the other? Is there any priority to posts that show the search terms more? Is it date based?
August 5, 2008 at 02:10
Does this work with WordPress MU 2.5+?
I can’t get it to work with my WordPress MU instalation.
August 29, 2008 at 15:38
i need member to choose search sitewide or main blog only
September 11, 2008 at 20:42
I would like to control what blog has this plugin activated.
Can I install it inside the normal wp-content/plugins folder instead of the mu-plugins folder?
September 15, 2008 at 09:13
Will this work on the latest versions of PHP, WordPress MU and MySQL?
September 16, 2008 at 05:38
The download links don’t work - is this code actually available somewhere?
October 19, 2008 at 22:28
i got it installed ok - i had to remove the version check. i have MySQL 5.0.51a, and once i removed the checks in the php code the views seemed to be created ok. however, i get zero results for all my queries…
any ideas on why / how to fix?
January 11, 2009 at 10:58
I am using WPMU 2.5.1 (for now). I had already set up 5 blogs, several pages and posts before trying to tie in the search results.
I installed this plugin into mu-plugins. I went to domain.com/?new=setup, but I still don’t get site wide search results. I tried creating a new blog and that didn’t help it initiate either.
I did make sure the blogs were set to public as well.
It doesn’t look like Jason has replied in awhile, so I may just abandon this….
January 11, 2009 at 17:22
Version 0.3.0 should work correctly. I removed the MySQL version checks that were creating problems. However, it will only work with MySQL 5.01 or higher.
January 14, 2009 at 10:02
Hi Jason,
your plugin seems very nice, but I’ve got a problem. Just installed a 2.6.5 version of Wordpress Mu and tried ‘One search’, and I’m getting weird results. The search seems to work, but in the results list every post is listed twice. For each couple of identical results, one lists “No comments” while the other lists “Comments off” (which is not true). Any idea why this is happening? Any advice or template hack to prevent the duplication?
Thanks a lot.
January 14, 2009 at 21:08
ink,
Thanks for stopping by. Things to check…
- conflicting plugin(s)
- search template code
- double check the data in your views (wp_v_posts, wp_v_comments, wp_v_postmeta)
I’ll follow up with an email.
January 23, 2009 at 11:48
Hey Jason,
I would like to be able to download your plugin, but each time I try to it says that the file is not there. Do you have another link that I can try?
Thanks!
January 23, 2009 at 21:03
Derek,
Thanks for the heads up. I’ve updated the link.
Let me know how it works out for you.
February 4, 2009 at 03:03
Hello,
I have installed this plugin, but search result is none.
I checked on my mysql it created wp_v_posts, wp_v_comments, wp_v_postmeta table. Is there something wrong with my installation.
Thank you
February 8, 2009 at 12:54
We’re running MySQL 5.0.67 and it’s not liking your views.
Is it possible we have too many blogs (17) and the view is overloaded?
February 9, 2009 at 16:51
Marc,
It’s probably not an overload. Where/when are you seeing this error? Are you possibly using a custom table prefix (other than wp_)?
If so, try version 0.4.0. That version correctly uses custom prefixes.
February 10, 2009 at 02:51
Nope, we’ve got the standard prefixes. I changed your CREATE VIEW SQL and ran it manually on the DB. Now it works. Basically I replaced “CREATE ALGORITHM=UNDEFINED DEFINER=Berra@`%` SQL SECURITY DEFINER VIEW Berra.wp_v_postmeta AS…” with “CREATE VIEW Berra.wp_v_postmeta AS…”.
February 20, 2009 at 00:31
I have installed this plugin, but nothing changed in search results. It searching only in current blog.
All three tables are successfully created in mySQL and showing clubbed data for all blogs.
Is there something needs to be change in search.php in selected theme or anywhere else.
Thank you
February 20, 2009 at 08:07
Kapil, Thanks for trying it out. Double check to see if there are other conflicting plugins. If there are, let me know which one(s) they are and I’ll look into what needs to be done.
February 23, 2009 at 02:26
Thanks jason for a quick reply.
I checked the code and found the bug, replace it
Line # 58: $v_query = preg_replace(”/{$wpdb->prefix}(\d+)_/”,”{$wpdb->prefix}v_”,$request);
with the following lines:
$v_query = preg_replace(”/{$wpdb->base_prefix}(\d+)_/”,”{$wpdb->base_prefix}v_”,$request);
$wpdb->prefix contains prefix including blog id (example: wp_1_, wp_2_, …) and $wpdb->base_prefix contains only base prefix (example: wp_)
Due to that query was not changed in onesearch_search_view function.
February 23, 2009 at 02:43
Thanks for this nice plugin.
Can we do the same for archive pages?
March 4, 2009 at 12:59
I have mysql 5.0.75. However, the 3 new tables don’t get created. No errors … just no tables. Any thoughts to at least generate some output to see the problem?
March 8, 2009 at 15:15
I have MySQL 5.1.32 and Wordpress MU 2.7.1 and the views don’t get created at all. I have another plugin that creates a table on the same database and has no problem.
If I run the build queries by hand they work perfectly!.
wpdb->query() returns ‘false’ every time these days.
Any ideas at all> please?
March 9, 2009 at 07:56
Eurika!! This works!! I’m no expert but here’s what I did:
1. I had to speak to my host and have them grant the appropriate permissions to the wordpress mysql user account for creating and removing VIEWS. Cpanel does not have that facility at least not on hostgator.com
2. Database pre-fixes are an issue. There were cases where
$wpdb->prefix was used where $wpdb->base-prefix was needed.
ie in the code that replaces the wordpress search table with the view stored in the database, this worked for me:
$v_query = preg_replace(”/{$wpdb->prefix}/”,”{$wpdb->base_prefix}v_”,$request);
AND the SQL that generates the views:
$v_query = “CREATE OR REPLACE VIEW `{$wpdb->base_prefix}v_posts` AS “;
Hope this helps someone
April 30, 2009 at 05:09
Hi,
thanks for the nice plugin. In my old Wpmu Version it worked fiine, but in the new, the search works only for the main blog.
Why? I hope, you can help me.
Lars
May 9, 2009 at 09:03
I had to do base_prefix mods above as well as change the queries to get it to work with my 2.7.1 MU install with about 20 blogs.
$posts_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 {$wpdb->base_prefix}{$blog->blog_id}_posts posts{$blog->blog_id}) “;
$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 {$wpdb->base_prefix}{$blog->blog_id}_postmeta postmeta{$blog->blog_id}) “;
$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 {$wpdb->base_prefix}{$blog->blog_id}_comments comments{$blog->blog_id}) “;
May 21, 2009 at 04:09
It is not working on my WPMU 2.7.1, only search in main blog, not in sub blogs. It seems I’m not the only one having this same problem ¿Which of the above mods will solve this issue? ¿Will this plugin be updated to solve it? thank you
May 24, 2009 at 04:39
problem is it need changes to themes.
and i have 200+ themes to choose from…
why not just make it a widget?
or just replace the default search like the original wpsearch does?
June 14, 2009 at 10:02
(site not live yet)
Two questions: First, I’ve tried all the code patches suggested above by knolly and Nick, but no luck yet getting it to search site wide.
I’m not seeing One Search in the plugins folder, though it did once create views. When I create a new blog (through admin panel) I get:
WordPress database error Invalid utf8 character string: ‘\xd41′ for query CREATE OR REPLACE VIEW `wp_v_postmeta` AS (SELECT \xd41\xd5 AS blog_id, \xd41\xd5 AS site_id, \xd4wpmu.sus
etc…
Second, I’ve also installed the Events Manager v.2 beta as the main feature of its own blog, and I’d like that to be searchable as well. It stores all its event data in a separate table at wp_(number of blog)_dbem_events. How do I include that in the views?
June 14, 2009 at 21:47
Addendum: There’s no reference to OneSearch currently listed in wp_sitemeta under active_plugins, though other plugins are showing up. But I do have wp_v_comments, wp_v_postmeta and wp_v_posts tables, so it must have worked at one time.