WordPress Sphinx Search Tutorial

Download the latest version from wordpress.org

Home page | Description | Installation | FAQ | Screenshots| Support


Description

WordPress Sphinx Search Plugin allows to use Sphinx Search Server power to enable ultra-fast and feature-rich search on WordPress-based websites. It is especially useful if your WordPress site becomes very large.

Search results are more relevant and you can search in posts, pages and comments using flexible search syntax, quickly sort the results by freshness or relevance. This plugin comes with sidebar widgets to display the most recent searches and top and related search terms.

This plugin replaces WordPress’s built-in search functionality.

Features

  • Use flexible search syntax
  • Sort search results by Relevance or Freshness
  • Search in posts, pages and comments
  • Friendly URLs support New!
  • Use extended search form to fine tune the results
  • Use sidebar widget for displaying Related/Top search terms
  • Use sidebar widget for displaying Latest search terms
  • Use Settings to style the keyword highlighting and search results
  • Sphinx configuration Wizard (via Settings)


Flexible search syntax

Sphinx allows you to use the following special operators in searchbox:

  1. Operator OR: hello | world
  2. Operator NOT: hello -world, hello !world
  3. Field search operator: @title hello @body world
  4. The following field operators are available:
    @title – search in title of post or page
    @body – search in body of post, page or comment
    @category – search in blog categories

  5. Phrase search operator: “hello world”
  6. Proximity search operator: “hello world”~10

Here’s an example query which uses all these operators:

"hello world" @title "example program"~5 @body python -(php|perl)

Read more on extended search syntax on Sphinx website: http://sphinxsearch.com/doc.html#extended-syntax


Installation

Requirments

  • WordPress 2.0.2 or higher
  • Ability to install Sphinx if not installed
  • Writable WordPress upload directory for Sphinx configuration files, logs and indexes

Step-by-step installation guide

Install the plugin:

  1. Unpack the plugin archive to wp-content/plugins folder of your WordPress installation
  2. Activate Sphinx Search plugin via WordPress Settings
  3. Make sure WordPress upload directory is writable by web server (by default WordPress is configured to use wp-content/uploads)
  4. Open Sphinx Search settings page and follow by Wizard steps to setup Sphinx Search Server and plugin configuration

Sphinx Configuration Wizard
Configuration Wizard

Most important steps:

  • In the 2nd wizard step you define Sphinx connection parameters which are used later by Sphinx Server.
  • In the 3rd step you may choose to use already installed Sphinx on your system (if exists) or install it from the latest installation archive that comes with plugin. If you choose to install Sphinx Server via wizard, be patient to wait several minutes while it finishes.
  • Then you need to specify paths to the Sphinx files like: indexes, config file and logs. (By default in our plugin these paths are set in the WordPress upload directory).
  • The following step will ask to run the indexer to build the search index. You may skip this step and index your data later on the plugin Settings page.
  • In “Configuration file” step you are informed about where the sphinx.conf is stored, also in this step you may open sphinx.conf configuration file generated by wizard.

Setup scheduled jobs to re-index your website data periodically

To setup periodical re-indexing, you should run Wizard to create special schedule files.

The default location of these files is: /path/to/wp-content/uploads/sphinx/cron/. When wizard finishes, edit your Crontab file.
Use “crontab -e” command in the Linux terminal and add the following lines to your crontab:

#Wordpress Delta index update
#Following cron job update delta index every 5 minutes:
*/5 * * * * /usr/bin/php /path/to/wp-content/uploads/sphinx/cron/cron_reindex_delta.php
#Wordpress Main index update
#Following cron job update main index daily (at 0 hours and 5 minutes):
5 0 * * * /usr/bin/php /path/to/wp-content/uploads/sphinx/cron/cron_reindex_main.php

Extended search form on search results page

<?php if (function_exists('ss_search_bar'))
    echo ss_search_bar();/*put it in search page*/?>

To find out if the current post is comment

<?php if (function_exists('ss_isComment') )
    if (ss_isComment()) echo 'It is comment'; else echo '';?>

Highlight search term in post title
Use the following function instead of the_title()

<?php sphinx_the_title(); ?>

Extended search form at the sidebar
Use “Sphinx Search sidebar” widget or add it as template tag:

<?php if (function_exists('ss_search_bar'))
    echo ss_search_bar(true); /*put it in sidebar*/?>

Related/Top searches at the sidebar
Use “Sphinx Related/Top Searches” widget or add it as template tag:

<?php if (function_exists('ss_top_searches')) ss_top_searches(); ?>

Top searches with pagination
Use “ss_top_searches_pager($max_per_page=10, $show_all=false)” template tag to enable pagination for top search terms:

<?php if (function_exists('ss_top_searches_pager')) ss_top_searches_pager(); ?>

Parameters:
* $max_per_page – limit how many search terms to display per page, by default 10
* $show_all – If set to True, then it will show all of the pages instead of a short list of the pages near the current page. By default, the ‘show_all’ is set to false

Latest searches at the sidebar
Use “Sphinx Latest Searches” widget or add it as template tag:

<?php if (function_exists('ss_latest_searches')) ss_latest_searches(); ?>

Faq

Q: What is Sphinx Search Server?
A: Sphinx is a full-text search engine which provides fast and relevant full-text search functionality. Read more on Sphinx website http://sphinxsearch.com

Q: How to install Sphinx Search manually?
A: To manually install Sphinx use the official Sphinx Search documentation.

Q: How to update the search index?
A: The best option to update search index is to setup cron job task for it. Also you may manually update search indexes through WordPress Sphinx Search administrative interface.

Q: How to run indexer manually
A: Open terminal and run following command:
/path/to/indexer -c /path/to/sphinx.conf --rotate --all

Q: I have just installed and run the wizard, however I have the following error message. What to do?
Can not start searchd, try to start it manually.

A: If you use version 2.1 or higher you can see the exact command below message “Can not start searchd, try to start it manually.” which you need to run manually through terminal on your server.
If you have ‘Permissions problem’ try to run the command as super user.

Q: When I run searchd or indexer I got ERROR: invalid section type ‘X-Powered-By’ in ../sphinx.conf line 1 col 1.
A: You are using CGI version of php, by default it shows a http header like “X-Powered-By: PHP/4.3.6″
To prevent this, PHP needs to be invoked with the ‘-q’ option for ‘quiet’. Open sphinx.conf in editor and change first line to:
#!/usr/bin/php -q

Q: I got WARNING: index ‘wp_main’: preload: failed to open /path/to/indexes/wp_main.sph No such file or directory; NOT SERVING
A: That means you have no indexes to serve. You need to build them. You may do it via wp-admin or manually:
On wp-admin>Settings>Sphinx Search page click “Re-index WordPress index”
Or use run this command manually in terminal:
/path/to/indexer -c /path/to/etc/sphinx.conf --all --rotate

Q: Sphinx installs fine, but when I go to search for something on the blog I get no results.
A: Check Sphinx version, Sphinx version should be 0.9.9 or higher.

Q: How do I modify the plugin php script to specify the path where I have Sphinx installed?
A: Run Sphinx Configuration wizard from WP Admin panel.
There are two important steps:
1. Install or use existing Sphinx binaries
There you can specify the path to your own indexer and searchd
2. Setup path to Sphinx indexes
There you can specify where to store index files and sphinx.conf file. This path should be writeable by web server.

Q: Cannot activate plugin. If I try to activate the plugin I get the following PHP error:
Fatal error: Cannot redeclare class SphinxClient in /home/wordpress/wp-content/plugins/wordpress-sphinx-plugin/php/sphinxapi.php

A: Check that you haven’t:
1. any other plugins which loaded Sphinx Search API library
2. Sphinx Search PECL extension installed

Q: I’ve got an error “Indexer: configuration files not found.” on clicking “Run Indexing & Contunue” (“Sphinx data indexing” step of Wizard).
A: Check that the user which is running your web server (it’s usually apache, www-data or smth like this)
can run indexer/searchd and can read/write into sphinx.conf. Then run Sphinx Configuration wizard from WP Admin panel again.

Q: How to set the maximum number of search results above 100.000?

A:
1) Go to Sphinx Search plugin directory and open rep/sphinx.conf in text editor.
2) Find max_matches parameter in searchd section at the bottom of the file
3) Set new value i.e. max_matches = 1000000
4) Open Sphinx Search control panel in WP Admin
5) Click on “Run Sphinx configuration Wizard” and skip all steps in the Wizard, it will rebuilds sphinx.conf file at the last step, click Finish.
6) Restart Sphinx Search (click on “Stop Sphinx daemon” and then “Start Sphinx daemon”)
7) Open tab “Search settings” and set the same max_matches value in the field “Maximum number of search results”.


Screenshots

Search in action:
Search results
Sidebar widgets

Top search terms widget:
Top search terms widget

Related search terms widget:
Related search terms

Latest search terms widget:
Latest search terms

Extended search form:
Extended Sphinx Search form

This search form is build as replacement for standard search form and it has following features:

  • Sort search results by Relevance or Freshness
  • Toggle search in posts, in pages and in comments
  • Exclude posts, comments or pages from search results

Support

This plugin is developed by Ivinco. If you need commercial support, or if you’d like WordPress Sphinx Search Plugin customized for your needs, we can help. Visit plugin website for the latest news.
See release notes, report bugs and feature wishes on WordPress: http://wordpress.org/extend/plugins/wordpress-sphinx-plugin/

91 Comments

EileenFebruary 21st, 2011 at 1:25 pm

Will this plugin search PDF files or other attached files on my site?

Sergey NikolaevFebruary 21st, 2011 at 1:30 pm

Hello Eileen.
This is not possible in the current version. We will implement this in future when we have time unless somebody urgently needs this and ready to sponsor the development :)

brusaccoFebruary 26th, 2011 at 1:11 am

Can we search TAGS too?

Sergey NikolaevFebruary 26th, 2011 at 4:55 am

We have it in plans, but have not yet implemented it.

AllisonMarch 7th, 2011 at 5:05 pm

Does this search custom taxonomies?

Yaroslav VorozhkoMarch 9th, 2011 at 2:35 pm

Allison,
No, not yet.

Mark WellsMarch 17th, 2011 at 8:37 pm

Hello,

I just installed sphinx on World Poverty and Human Rights Online – http://wphr.org, a site that I edit and admin. We publish a lot of student articles (hendreds per semester) and I was wondering if there was any way to get sphinx to search in the “post” area through submitted or draft articles by author name?

I’ve tested it, and so far it doesn’t seem to have this functionality as evidenced by a search I just did for an author’s last name(for a draft post that does exist), and it failed to return any results.

Is there any way to add this functionality? It would really help with wading through hundreds of submissions when we don’t always know what username or email the person signed up with(students sometimes use different emails or maiden names to sign up). If a student saves their submission as a draft, or if they haven’t had an article published yet, there is no way to get a list of pending/draft articles, and we REALLY need to be able to do that.

The default post search in wordpress is sub-useless at this point, so I was hoping sphinx might fill in the gap.

Any chance of that?

Thank you,
Mark Wells
Editor, WPHR.org

Sergey NikolaevMarch 18th, 2011 at 4:00 am

Hello Mark
Search by author name and in drafts is not possible in the current version, but it’s absolutely doable. We will implement this in future when we have time unless somebody urgently needs this and ready to sponsor the development. This way we can implement it within few days. Please feel free to contact us via info@ivinco.com.

ToniMarch 23rd, 2011 at 8:21 pm

I have just installed and run the wizard, however I have the following error message. What to do?

Can not start searchd, try to start it manually.

Yaroslav VorozhkoMarch 24th, 2011 at 7:24 am

Hello Toni,
If you use latest version 2.1 you may see the instruction commands below message “Can not start searchd, try to start it manually.” which you need to run manually through terminal on you server.
It will help diagnose a problem.
If you will have ‘Permissions problem’ try to run command as super user.

Akordeonista PMMarch 31st, 2011 at 4:06 am

Hello, I would like to know if I install Sphinx to use with wordpress i can still have it indexing my other websites, so my visitors can search trough all my sites.

Thanks,

PM Akordeonista

Sergey NikolaevMarch 31st, 2011 at 4:16 am

Hello Akordeonista PM

You don’t need to install separate Sphinx for your wordpress. You can reuse the one you use for other purposes/sites. But you won’t be able to unite searches on other sites and your blog easily. So your visitors will be able to search through all your sites, but each site separately.

ArtobalApril 7th, 2011 at 2:33 pm

Hello, how do i modify the plugin php script to specify the path where i have Sphinx installad (it don’t recognise it) ?

Yaroslav VorozhkoApril 8th, 2011 at 6:36 am

Artobal,
Run Sphinx Configuration wizard from WP Admin panel.
There are three important steps:
1. Connection parameters
hostname, port and prefix for sphinx indexes
2. Install or use existing sphinx binaries
There you can specify path to your own indexer and searchd
3. Setup path to sphinx indexes
There you can specify where to store index files and sphinx.conf file. This path should be writeable by web server.

IlyaApril 9th, 2011 at 11:39 am

I’ve got an error “Indexer: configuration files not found.” on clocking “Run Indexing & Contunue” (“Sphinx data indexing” step of Wizard).

I have manually installed sphinx 0.9.9 (without any problems) specially for this purpose on debian squeeze.

PS Must be “Index name” on the “Set sphinx connection parameters” step same as prefix for MySQL DB of blog?

Yaroslav VorozhkoApril 11th, 2011 at 7:54 am

Hello Ilya,
Run Sphinx Configuration wizard from WP Admin panel again.
There are two important steps:
1. Install or use existing Sphinx binaries
There you can specify the path to your own indexer and searchd

2. Setup path to Sphinx indexes
There you can specify where to store index files and sphinx.conf file. This path should be writeable by web server.

Correct execution of this step should solve “Indexer: configuration files not found.” problem.

You can choose any “Index name”, only one restriction that “Index name” can’t be empty string.

Yaroslav VorozhkoApril 11th, 2011 at 11:54 am

Illia, also please check that web user can run indexer/searchd and can read/write into sphinx.conf.

TerryApril 18th, 2011 at 10:00 am

Is it possible to delete search terms in control panel?

I only see “Mark as approved” and “Mark as banned” actions in Bulk Actions selection.

Anyway, thank you very much for providing so good wordpress plugin for us, thank you.

Yaroslav VorozhkoApril 18th, 2011 at 11:13 am

Terry, thank you for good feedback.

Unfortunately, it is not possible to remove search terms in control panel.

Currently, only way delete search terms it is to use MySQL command.

Jeff C.May 12th, 2011 at 2:00 pm

I hate having to ask this question and potentially sound retarded, but I’m having issues with the Sphinx installation on my WordPress-based site.

Specifically, I can’t figure out how to get past step one. At the “Set Sphinx connection parameters” screen on the install, I tried a number of combinations for host name, port and index name (currently, I’m back to the default of localhost/9312/wp_ and the uploads directory is writeable), but when I attempt to install Sphinx on the following screen, I get a message reading:

Installation: Sphinx installation error, try to run this command manually in Terminal:
Command: ./configure –with-mysql –prefix=/home/content/j/c/l/[myname]/html/wp-content/uploads/sphinx 2>&1 at the directory:/home/content/j/c/l/[myname]/html/wp-content/uploads/sphinx/sphinx-0.9.9
try running it with sudo if it doesn’t work

What am I doing wrong?

Yaroslav VorozhkoMay 12th, 2011 at 3:20 pm

Hello Jeff,
Looks like you need to try to install Sphinx Search manually,
detailed instructions described here: http://sphinxsearch.com/docs/current.html

If you need installation advice or help, don’t hesitate to ask us.

Rotten MonkeyMay 16th, 2011 at 8:15 pm

Yaroslav: I am about to install Spinx for the first time on a demo site of mine (using your plugin, of course). I have checked with my hosting provider and they say that my hosting plan will support it, so I’m good there, however, this is obviously a more complex installation than a typical plugin, so I have a couple of questions for you.

1) What information (parameters, etc.) should I have at the ready when I install the plugin?

2) What common installation problems do people run across, so that I can be more prepared on how to avoid them?

3) What are the common plugins that interfere with your plugin’s ability to install or work properly (so I can be sure to deactivate or delete them)?

Thanks in advance for your assistance. I have a really good feeling about this plugin and it’s ability to accomplish the feats that I need it to.

Yaroslav VorozhkoMay 19th, 2011 at 9:20 am

Hello,
> 1) What information (parameters, etc.) should I have at the ready when I install the plugin?
After plugin activation, sphinx configuration Wizard will guide you. In Wizard you may choose all default parameters.

> 2) What common installation problems do people run across, so that I can be more prepared on how to avoid them?
Many of them mentioned at FAQ on this page.

> 3) What are the common plugins that interfere with your plugin’s ability to install or work properly (so I can be sure to deactivate or delete them)?
I don’t know any. Maybe other search plugins, let me know if you will face with such problems.

Rotten ElfJune 28th, 2011 at 5:22 am

I have installed Sphinx on a playground domain with a wordpress installation and dummy content, however, I seem to be at a roadblock of sorts. When I ran the installation wizard i got the following:

Can not start searchd, try to start it manually.

So i typed the command line into the server terminal with superuser and it gave me:

ERROR: invalid token in /home/bizhelp/public_html/wp-content/uploads/sphinx/sphinx.conf line 1 col 1.
ERROR: invalid token in /home/bizhelp/public_html/wp-content/uploads/sphinx/sphinx.conf line 1 col 1.
FATAL: failed to parse config file ‘home/bizhelp/public_html/wp-content/uploads/sphinx/sphinx.conf’

So of course I came here and looked at the FAQ and found this:

Q: When I run searchd or indexer I got ERROR: invalid section type ‘X-Powered-By’ in ../sphinx.conf line 1 col 1.
A: You are using CGI version of php, by default it shows a http header like “X-Powered-By: PHP/4.3.6″
To prevent this, PHP needs to be invoked with the ‘-q’ option for ‘quiet’. Open sphinx.conf in editor and change first line to:
#!/usr/bin/php -q

Thinking since it was the same line and column (minus the ‘x-powered-by’ scripting), and I know that I am running CGI version of php (at least i’m 90% sure) I went to add the provided script to line 1 of sphinx.conf file, however, i found several sphinx files including:

sphinx.conf.in
spinx.conf.dist
sphinx.spec
sphinx.workspace
sphinx03.sln
sphinx05.sln
sphinx08.sln
sphinx-min.conf.dist
sphinx-min.conf.in

HOWEVER….i could find no file named ‘sphinx.conf’ what-so-ever.

I am at a loss here.

I was using Super User on my server, so I know that I have permissions. What else could it be?

Yaroslav VorozhkoJune 28th, 2011 at 2:48 pm

Hello,
sphinx.conf should be at: /home/bizhelp/public_html/wp-content/uploads/sphinx/sphinx.conf
First line should look like:
#!/usr/bin/php -q
This parameter -q should prevent any output for CGI version of PHP if not try CLI version.

Rotten ElfJune 29th, 2011 at 2:05 am

Yaroslav:

First of all, thank you for your reply. I am excited about getting going with this plugin.

The sphinx.conf file is not there. The installation wizard went fine, except for the issue I mentioned above. Do you have a sphinx.conf file that you could send me that I could modify for the proper pathnames within my own server by chance? Or is there a sphinx.conf configuration command that I can run in the terminal…or perhaps a command that I could run within the wordpress plugin you created? Please advise. Thank you in advance.

Rotten ElfJune 29th, 2011 at 2:06 am

….Or perhaps you have a tutorial on your site that you can reference me to? I’m pretty savvy, however, the spinx.conf file is simply not there :(

Rotten ElfJune 29th, 2011 at 2:23 am

Yaroslav:

WOW…i found it….I was looking at an almost identical pathname.

The sphinx.conf file is there, and the 1st line of code is the:

#!/usr/bin/php -q

so…now that we know that isn’t the problem. According to my earlier post, what do you think the issue is?

Yaroslav VorozhkoJune 30th, 2011 at 8:45 am

What version of Sphinx Search do you use?
Do you install Sphinx Search manually?

Rotten ElfJune 30th, 2011 at 3:19 pm

I uploaded the plugin via wordpress. I downloaded it from you guys a few weeks ago, if I’m not mistaken.

Rotten ElfJune 30th, 2011 at 5:55 pm

Wow….I just realized that I didn’t put the software version. Sorry Yaroslav. I am using Sphinx 3.0

Rotten ElfJuly 3rd, 2011 at 3:10 am

@Yaroslav: I could really use a little guidance on this. Sphinx is definitely the search protocol for my project, however, the wizard did not install everything correctly apparently. I would really appreciate it if you could look at my initial post and give me a little direction, as I’m hitting a brick wall. :(

Rotten ElfJuly 7th, 2011 at 4:14 am

Yaroslav Vorozhko?

Yaroslav VorozhkoJuly 7th, 2011 at 11:45 am

Could you show your sphinx.conf file: /home/bizhelp/public_html/wp-content/uploads/sphinx/sphinx.conf

Rotten ElfJuly 11th, 2011 at 12:39 am

Sure thing Mr. Yaroslav Vorozhko.

http://projectid10t.com/my-sphinx-conf-file.txt

There it be sir. I copied and pasted it into a notepad file and uploaded it to a playground domain. Please let me know where the issue is….I’m thoroughly perplexed on this one.

Rotten ElfJuly 11th, 2011 at 1:37 am

Yaroslav: Just to give you a heads up. I just got done trying to run sphinx on a fresh wp install with about 20 posts of dummy content.

There are no plugins on the wp install (except sphinx of course).
It is the wp Twenty-Ten theme with no mods.

I got this error:
Indexer: reindexing error, try to run it manually.
Command: /home/id10t/public_html/test/wp-content/uploads/sphinx/bin/indexer –config /home/id10t/public_html/test/wp-content/uploads/sphinx/etc/sphinx.conf wp_delta wp_main wp_stats

When I tried to run the command manually with SSH via Superuser, I got this error:

ERROR: invalid token in /home/id10t/public_html/test/wp-content/uploads/sphinx/sphinx.conf line 1 col 1.
ERROR: invalid token in /home/id10t/public_html/test/wp-content/uploads/sphinx/sphinx.conf line 1 col 1.
FATAL: failed to parse config file ‘home/id10t/public_html/test/wp-content/uploads/sphinx/sphinx.conf’

So, I’m wondering where the issue is. I was hoping that it was my wordpress install on the other domain or some other active plugin…but now I’m at a loss. Any help would be greatly appreciated.

Rotten ElfJuly 11th, 2011 at 1:38 am

…using 3.3 sphinx

Yaroslav VorozhkoJuly 11th, 2011 at 6:20 am

This command:
/home/id10t/public_html/test/wp-content/uploads/sphinx/bin/indexer –config /home/id10t/public_html/test/wp-content/uploads/sphinx/etc/sphinx.conf wp_delta wp_main wp_stats

Using /home/id10t/public_html/test/wp-content/uploads/sphinx/etc/sphinx.con

But, in the output I see link to other sphinx.conf: /home/id10t/public_html/test/wp-content/uploads/sphinx/sphinx.conf

What sphinx.conf did you show me in the previous post?

Yaroslav VorozhkoJuly 11th, 2011 at 6:20 am

Compare the paths:
/home/id10t/public_html/test/wp-content/uploads/sphinx/etc/sphinx.conf
and
/home/id10t/public_html/test/wp-content/uploads/sphinx/sphinx.conf

adminJuly 11th, 2011 at 11:21 am

test

Rotten ElfJuly 12th, 2011 at 12:59 am

The sphinx.conf that was in the previous post is the correct one.

/home/id10t/public_html/test/wp-content/uploads/sphinx/etc/sphinx.conf

The missing ‘/etc/’ was an error on my part when transposing the command line from SSH (as explained in my wordpress post)

Rotten ElfJuly 12th, 2011 at 1:08 am

Actually….the sphinx.conf file that I posted for you to view was the one that I was having the problems on originally. If you remember, I switched domains and wp installs to see if the issue lied with my wp install or my domain. But I just reviewed the sphinx.conf file for the second path:

/home/id10t/public_html/test/wp-content/uploads/sphinx/etc/sphinx.conf

Both sphinx.conf files are the exact same, except they obviously have different path names for their respective domains and wp installs. However, if you use the same link above:

http://projectid10t.com/my-sphinx-conf-file.txt

I have replaced it with the “projectid10t.com/test/” sphinx.conf file for you to review.

Yaroslav VorozhkoJuly 12th, 2011 at 6:56 am

I suggest following experiment. Copy following code to separate file. i.e test.php:
#!/usr/bin/php -q
< ?php
error_reporting(0);
$path_to_config = "/home/id10t/public_html/test";
if ( file_exists( $path_to_config . '/wp-config.php') ) {

/** The config file resides in ABSPATH */
require_once( $path_to_config . '/wp-config.php' );

} elseif ( file_exists( dirname($path_to_config) . '/wp-config.php' ) && ! file_exists( dirname($path_to_config) . '/wp-settings.php' ) ) {

/** The config file resides one level above ABSPATH but is not part of another install*/
require_once( dirname($path_to_config) . '/wp-config.php' );

}
ini_set('short_open_tag', 0);
?>

run it from ssh, like:
php test.php

I expected no output, but will see.

Rotten ElfJuly 13th, 2011 at 3:38 pm

I ran the command in SSH:

php /home/id10t/public_html/test/test.php

All that did was display the script within the file:

#!/usr/bin/php -q

After that, it simply brought up my command prompt. No other output what-so-ever.

Rotten ElfJuly 13th, 2011 at 3:41 pm

I don’t know what is going on with your commenting system. I tried to display the screen within your comment box exactly as it was on my SSH, but it would not allow me to do so. Basically, it just pulled up the screen from the test.php that you had me create and then the command prompt was displayed again. I did this in superuser as well. Let me know what we need to try next. Thank you in advance.

adminJuly 14th, 2011 at 6:56 am

Check the path to the PHP, command:
whereis php.
By default it is /usr/bin/php, but it may be /usr/local/bin/php or php executive can be named as /usr/bin/php-cgi or /usr/bin/php-cli

Rotten ElfJuly 14th, 2011 at 6:52 pm

Which PHP file are you speaking of? Or are you talking about the PHP folder?

If you are talking about the php folder it is in wp-content/uploads/plugins/sphinx-search-plugin/php

Yaroslav VorozhkoJuly 15th, 2011 at 6:22 am

I am talking about path to PHP binary. Commands above could help you determine the correct path.

AudreyJuly 26th, 2011 at 2:54 am

The plugin is installed successfully but I’m getting the following error when I tried to make a search.

Fatal error: Call to undefined function home_url() in /home/voiceraa/public_html/wp-content/plugins/wordpress-sphinx-plugin/sphinxsearch.php on line 513

Can you please help? Thanks!!

Yaroslav VorozhkoJuly 26th, 2011 at 4:20 pm

Audrey,
home_url was introduced in WordPress version 3.0.
Upgrade to latest WordPress version if it is possible for your.

Or you could implement following fix:
Open sphinxsearch.php and find following code on line 513
wp_redirect( home_url( $permPrefix . ‘/search/’ . urlencode(get_query_var( ‘s’ )) .’/’ ) . $query_string );
replace it by:
wp_redirect( get_option(‘home’) . $permPrefix . ‘/search/’ . urlencode(get_query_var( ‘s’ )) .’/’ . $query_string );
It should fix the problem.

This problem would be fixed in next release.

KristoferAugust 5th, 2011 at 3:37 pm

Hi there,

this is a great plugin!

As we use the plugin “magic fields” I’m wondering if i can make Sphinx to search through the magic fields / meta values too? Would that be possible through editing the sphinx.conf file?

Thanks in advance,
Kristofer

Yaroslav VorozhkoAugust 8th, 2011 at 8:23 am

Kristofer, yes it is possible. You should find relations between custom fields and pages/comments tables and modify SQL query in sphinx.conf to load data from custom fields table.
Source blocks in sphinx.conf for pages and comment should have equal number of fields.

Yaroslav VorozhkoAugust 8th, 2011 at 8:27 am

Kristofer,
We already did similar customisation, so if you need commercial support, we can help.

RogerAugust 11th, 2011 at 2:45 pm

Great plugin, works very well!!!

is there a way to have it running when using a feed-rss as for example
http://www.mysite/search/searched_term/feed/

thanks in advance
Roger

Yaroslav VorozhkoAugust 11th, 2011 at 5:45 pm

There is no such feature yet – we’ll add it to our further development plans. If you need such feature now – we provide commercial support service and we could change our plans to help you faster.

IlyaSeptember 14th, 2011 at 1:57 am

I have a problem with your plugin on WordPress 3.2.1, Debian 6.0, Sphinx 2.0.1-beta.

I have tried to use system libraries and built-in Sphinx 0.9.9 for you plugin, but always i have got an error:

root@sigma:~# /usr/local/bin/searchd –config /var/www/blogs/data/www/podebrady.ru/wp-content/uploads/sphinx/sphinx.conf
Sphinx 2.0.1-beta (r2792)
Copyright (c) 2001-2011, Andrew Aksyonoff
Copyright (c) 2008-2011, Sphinx Technologies Inc (http://sphinxsearch.com)

using config file ‘/var/www/blogs/data/www/podebrady.ru/wp-content/uploads/sphinx/sphinx.conf’…
ERROR: invalid token in /var/www/blogs/data/www/podebrady.ru/wp-content/uploads/sphinx/sphinx.conf line 231 col 1.
ERROR: invalid token in /var/www/blogs/data/www/podebrady.ru/wp-content/uploads/sphinx/sphinx.conf line 231 col 1.
FATAL: failed to parse config file ‘/var/www/blogs/data/www/podebrady.ru/wp-content/uploads/sphinx/sphinx.conf’

This 301 line contains “indexer”:

indexer
{
mem_limit = 32M
}

I have not any idea :(

Sergey NikolaevSeptember 14th, 2011 at 5:19 am

Hi Ilya. Please send the whole sphinx.conf to opensource@ivinco.com. I’d like to look into this.

IlyaSeptember 14th, 2011 at 2:54 pm

Sergey, I have sent a sphinx.conf to opensource@ivinco.com. Thanks.

Krasen TomovSeptember 22nd, 2011 at 1:37 pm

I’ve saw that the last answer for custom taxonomies was from March.
I want to ask you if there are plans on getting this function in the future releases?
I managed to integrate sphinx in my website and I have lots taxonomies for which i need options to search in.
Hope there will be option for that soon.
Regards

Yaroslav VorozhkoSeptember 27th, 2011 at 11:57 am

Hello Krasen Tomov,
thank your fo remind us about taxonomies support.
Now we are discussing this subject, but I couldn’t promise that taxonomies would be implemented in near month.
Of course we have commercial support, if your need it soon, we can help!
Thank you for your understanding.

SergeyOctober 19th, 2011 at 9:43 am

I installed your Plugin, but can not find anything on my site (empty search results).

WordPress Sphinx Search Plugin 3.3.1

Krasen TomovNovember 15th, 2011 at 1:29 pm

By the look of it my last comment from yesterday, have gone in the spam folder, because the last time I’ve commented here, at least I’ve say that the comment is on hold for moderation.
So once again – I’ve updated the php on my server. Using 5.2.17 now. Until then sphinx was working okay with my wordpress installation.
The problem is that, I have the searchd started, I can run indexer, I can use the search to search in the database – everything looks fine.
The problem is that I only get Warning: Sphinx Search Server is NOT running. in my wp-admin.
I’ve tried reinstalling the plugin, recompiling the sphinx using the default config, changed the ports, the listening address and still nothing.
Any advice is welcomed.
Regards,
Krasen

Yaroslav VorozhkoNovember 15th, 2011 at 2:05 pm

Krasen,
could you please check searchd PID in sphinx/logs/searchd.pid file and actually running searchd pid using:
`ps aux|grep searchd`
If PID in file and PID from command are different when stop sphinx, remove searchd.pid file manually and start sphinx again.
BTW, this searchd.pid file should be readable by web server user.

Krasen TomovNovember 15th, 2011 at 2:20 pm

Oh I finally got it. I’ve read all the threads in the wordpress, I’ve come across a post about the exec() function.
Checking that in my php.ini it turns out that the function was disabled, removing it from disable_function and restarting the apache, made the difference.
It turns out that this script php/sphinx-service.php wasn’t successfully executed, because of the exec function.

Just an opinion – you’ve better put a check for that in your next versions and if the function is disabled as in my case, an error message shoud be show, saying “You have the php exec function disabled”.

Hope that this will help to someone like me – headbanging for 3 days with such a small problem.

Best Regards,
Krasen

Yaroslav VorozhkoNovember 15th, 2011 at 2:21 pm

Sergey, make sure that sphinx is installed.
1. Go through Installation Wizard, when check that directory uploads/sphinx contain sphinx.conf and bin directory with indexer and searchd inside.
2. Check SphinxSearch admin page and make sure Sphinx is running.
3. Run re-indexing of all posts once again.

Krasen TomovNovember 15th, 2011 at 2:22 pm

Yaroslav – everything was working fine – manually started searchd, indexer and everything else. Apache has the rights to read/write the pid file, data and log files.
The only problem was with the exec function.

Thanks for your fast reply!

Yaroslav VorozhkoNovember 15th, 2011 at 2:26 pm

Krasen,
Thank you for feedback, it is good idea.

charliesDecember 9th, 2011 at 5:10 am

Thank you for your sharing,
does the plugin support real time function now?

Sergey NikolaevDecember 9th, 2011 at 5:50 am

Hi Charlies. No, the plugin doesn’t support real time function yet although new posts get indexed quite soon after they’re added.
We’re open for commercial customization requests if you need the real time.

LennartDecember 10th, 2011 at 1:53 am

Does this plugin support searching bbPress?

Sergey NikolaevDecember 19th, 2011 at 3:40 am

Hi Lennart

We never tried actually, but since bbPress seems to be a different thing than wordpress I don’t think the plugin will work there. Perhaps sometimes we will create another plugin for bbPress.

LennartDecember 19th, 2011 at 4:16 am

Thanks Sergey,

Maybe most of what is needed is there already since bbPress forum contents can be search through the normal wordpress search?

Krasen TomovDecember 30th, 2011 at 5:46 pm

Hi there!

Can you point me, which files should I edit in order to change the permalink? So instead of /search/string I would get /result/string.
I’ve replaced /search/ in sphinxsearch.php on the 3 places that it was found but then I get an error.

Regards

Yaroslav VorozhkoJanuary 6th, 2012 at 1:50 pm

Hi Krasen,

did you try rewrite rules, like:
^/search(.*) /result$1

Information about rewrite rules for Apache http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewriterule

Yaroslav VorozhkoJanuary 6th, 2012 at 2:02 pm

Other solution is to redefine default search base:

Add following code in sphinxsearch.php

add_action( ‘init’, ‘wpsphinxsearch_init’ );
function wpsphinxsearch_init()
{
$GLOBALS['wp_rewrite']->search_base = ‘result’;
}

And make sure that ‘search’ replaced by ‘result’ in sphinx_search_friendly_redirect function.

Let me know if it works for your.

PvUtrixFebruary 5th, 2012 at 9:56 am

Good day! Thank you for the wonderful plugin! At last my blog can be searched properly!
Advanced search feature doesn’t work for me though, @title search for instance, I get no results
http://pozitivchik.info/search/%40title+%D0%B3%D1%80%D0%B8%D0%B1/
where as without the @title
http://pozitivchik.info/search/%D0%B3%D1%80%D0%B8%D0%B1/
I get results and the first one is with the mentioned keyword in the title.

Sergey NikolaevFebruary 6th, 2012 at 2:15 am

Hello PvUtrix

Could you send me your Sphinx query log (including ‘@title гриб’ query) to opensource@ivinco.com? I think smth might be wrong with keyword escaping on some level or plugin configuration.

AdnanFebruary 22nd, 2012 at 9:43 am

First of all thank you very much for this plugin!
I am having a problem with it tough. It works fine as long as the search keyword can be found on my site. But If the keyword can’t be fined (doesn’t exist) I get this error (I have removed my URL from the error message below):

Warning: Invalid argument supplied for foreach() in /home/admin/domains/xxxxxxxx/public_html/wp-includes/query.php on line 2746

Warning: Cannot modify header information – headers already sent by (output started at /home/admin/domains/xxxx/public_html/wp-includes/query.php:2746) in /home/admin/domains/ xxxxxxxx/public_html/wp-includes/pluggable.php on line 866

Thank you in advance for any help!

Yaroslav VorozhkoFebruary 22nd, 2012 at 12:38 pm

Hello Adnan,
you need to check your wp-config.php, probably debug mode is enabled.

If it wouldn’t help, post 3 lines before and after the line 2746 of /home/admin/domains/xxxxxxxx/public_html/wp-includes/query.php

I can’t check it on my WP, because it seems our version of WP is different.

AdnanFebruary 22nd, 2012 at 4:11 pm

Thank you for your fast reply! debug mode is dissabled so I am posting 3 lines before and after the 2746 line. 2746 line is the one that starts with “foreach”.

if ( !$q['suppress_filters'] )
$this->posts = apply_filters_ref_array(‘the_posts’, array( $this->posts, &$this ) );

$this->post_count = count($this->posts);

// Always sanitize
foreach ( $this->posts as $i => $post ) {
$this->posts[$i] = sanitize_post( $post, ‘raw’ );
}

if ( $q['cache_results'] )
update_post_caches($this->posts, $post_type, $q['update_post_term_cache'], $q['update_post_meta_cache']);

Sergey NikolaevFebruary 23rd, 2012 at 2:09 am

Hi Adnan

Please read these threads that are about the exactly same issue:
http://wordpress.org/support/topic/oenology-warning-invalid-argument-supplied-for-foreach
http://wordpress.org/support/topic/warning-invalid-argument-supplied-for-foreach-pleae-help
http://wordpress.org/support/topic/images-giving-errors-but-work-fine

In 2 of them disabling “Ultra hide comments” plugin helped. Are you using this?

AdnanFebruary 23rd, 2012 at 7:01 am

I am not using ”ultra hide comments” plugin but it doesn’t really matter because the problem was solved by itself. Really strange because I haven’t changed anything at all. Anyway thank you very much for all the help!

jamesApril 1st, 2012 at 5:53 pm

will this search engine be useful for my social network site which has games,videos and profile apps on

Sergey NikolaevApril 2nd, 2012 at 2:23 am

Hello James

If you need fast search on the site it can be useful out of the box. Also if you want to be able to split separately by games/videos/profile apps please contact us at opensource@ivinco.com and we can develop this feature for you.

RobertMay 1st, 2012 at 12:13 am

Hello,

After upgrading to wp 3.3.2, sphinx is not working anymore. I tried reinstalling the plugin, and even recompiling sphinx but no succes. When I try to index my posts through the control panel I get this error message:

Indexer: reindexing error, try to run it manually.
Command: /usr/local/bin/indexer –rotate –config /usr/share/nginx/html/wp-content/uploads/sphinx/sphinx.conf wp_delta wp_main wp_stats

When runing the command I get the following errors:

using config file ‘/usr/share/nginx/html/wp-content/uploads/sphinx/sphinx.conf’…
ERROR: invalid token in /usr/share/nginx/html/wp-content/uploads/sphinx/sphinx.conf line 1 col 1.
ERROR: invalid token in /usr/share/nginx/html/wp-content/uploads/sphinx/sphinx.conf line 1 col 1.
FATAL: failed to parse config file ‘/usr/share/nginx/html/wp-content/uploads/sphinx/sphinx.conf’

My sphinx.conf is as follow: http://pastebin.com/1qKHwfys

Another glitch I noticed, it seems like the plugin thinks that searchd is running, while it’s not (reason above) and trying to stop it from the control panel results in a similar error as above (issue with the config file at line 1 col 1)

Regards

Sergey NikolaevMay 1st, 2012 at 3:40 am

Hello Robert

Could you please try to execute the sphinx.conf (it’s actually an executable file) and let me know the output you see?
What Sphinx version do you have installed btw?

RobertMay 1st, 2012 at 1:02 pm

Hello,

Thanks for the hint, I’ve found the problem: after executing sphinx.conf, the problem became clear, for some reason wordfence (a security plugin) was blocking the execution of that script (it was giving a 503 error). I’ll contact the plugin author and let him now about the issue. Thank you for the support :)

Regards

OlegMay 15th, 2012 at 6:56 pm

Hello, help me pls.
At the begining of the Install the error :Installation: Sphinx installation error, try to run this command manually in Terminal:
Command: ./configure –with-mysql –prefix=/home/professa/public_html/wp-content/uploads/sphinx 2>&1 at the directory:/home/professa/public_html/wp-content/uploads/sphinx/sphinx-0.9.9
try running it with sudo if it doesn’t work.

Sergey NikolaevMay 16th, 2012 at 4:26 am

Hello Oleg

Probably the plugin doesn’t have enough permissions to run this command, that’s why it suggested you to run it manually. Did you try to run that?

OlegMay 16th, 2012 at 1:05 pm

How i can do it, if my blog stay on hosting?

Sergey NikolaevMay 16th, 2012 at 1:06 pm

Then I guess you should ask your hosting provider to install Sphinx which you can use then.

Leave a comment

Your comment

Notify me of followup comments via e-mail. You can also subscribe without commenting.