Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Sphinx 0.1: $SphinxSearchForm / no enabled local indexes to search


Go to End
Reply


59 Posts   12148 Views

Avatar
aimcom

Community Member, 8 Posts

30 June 2010 at 9:43pm

Edited: 30/06/2010 9:44pm

Hello everybody,

I have some severe problems using the Sphinx module.

First of all, using $SphinxSearchForm in a template doesn't show a search form. I had to build a workaround for the Page_Controller but I don't think that this is the way it should be:

public function SphinxSearchForm() {
   $SphinxSearchForm = new SphinxSearchForm($this, 'search');
   return $SphinxSearchForm->forTemplate();
}

The major problem that I experienced is that I don't get proper results after sending the search query. I added this method to the Page_Controller:

public function search($arguments) {
   $SphinxSearchForm = new SphinxSearchForm($this, 'search');
   $SphinxSearchForm->getResults();
}

The error message is "[User Error] no enabled local indexes to search". I searched some Sphinx forums where confusing solutions were posted. As the configuration file for Sphinx is built by SilverStripe, I didn't want to manipulate the sphinx.conf on my own - furthermore I don't have enough knowledge to do so. Perhaps somebody has an idea how to solve this issue.

Avatar
mark_s

Community Member, 78 Posts

4 July 2010 at 9:01pm

Hi there.

Sphinx is a more complicated module than many because of it's external dependencies. We're attempting to make it better by making it easier to set up, and also easier to report problems. If you are just starting out with sphinx, I would recommend that you use trunk of the module. I'm anticipating that a 0.2 release will happen within the next week or so, which is pretty much what trunk is now. With this latter version, you can visit yoursite/Sphinx/diagnose (or from the command line, `sapphire/sake Sphinx/diagnose`), which is a good place to start in troubleshooting. Specific thing to look for are:

* the sphinx.conf file is being generated in the temp directory (the project temp folder has a sphinx folder, with a sphinx.conf file, and the idxs directory where the actual indexes are generated by the search daemon)
* the temp directory reported by Sphinx/diagnose is what you expect
* there is at least one class decorated with SphinxSearchable
* the connection properties to the database in sphinx.conf are correct (I'm assuming you're using MySQL).
* the searchd process is running.
* permissions are correct. I recommend that files are owned by www-data, or whatever apache uses, and run searchd as that too.
* ensure you are using 64-bit compilations of sphinx.
* try forcing a reindex by visiting yoursite/Sphinx/reindex. See if any errors are reported by that.

Trunk also contains a mode called xmlpipes, which offers an alternate way to provide data to the indexer. Apart from the extra functionality it provides, it can be easier to debug, because you can directly see what data is provided to the indexer.

Mark

Avatar
aimcom

Community Member, 8 Posts

6 July 2010 at 2:12am

First of all, thank you for your suggestions. It looks like the problem is the connection to the database.

sake Sphinx/reindex


returns the following error:

ERROR: index 'SiteTree': sql_connect: Can't connect to MySQL server on '127.0.0.1' (111) (DSN=mysql://sphinx_search:***@127.0.0.1:3306/sphinx_search).

I looked at the configuration file of Sphinx in the temp folder and checked whether the database configuration in the "source BaseSrc" is correct. The problem is that I cannot find an error here, the credentials for MySQL seem to be correct. SilverStripe itself uses the same credentials and it works.

Avatar
mark_s

Community Member, 78 Posts

6 July 2010 at 9:15am

Hi.

What version of SilverStripe are you running?

Can you attach the sphinx configuration file as well?

Is SilverStripe also connecting to 127.0.0.1, or to localhost?

Mark

Avatar
aimcom

Community Member, 8 Posts

6 July 2010 at 9:01pm

Edited: 06/07/2010 9:06pm

Thank you again for your help, mark_s.

Is SilverStripe also connecting to 127.0.0.1, or to localhost?


This was a good hint. ;) I can't connect to MySQL using 127.0.0.1 as host address so I changed the sphinx.conf:

source BaseSrc {
   sql_host = localhost
   // ...
}


Now sake Sphinx/reindex returns OK and sake Sphinx/diagnose tells me that everything works fine. :) I had to edit one line in the Sphinx module so that running /dev/build doesn't change the sql_host setting back to 127.0.0.1.
Using the code that you can see in my first posting in this topic, I can get valid results from Sphinx. :)

I managed to add the SphinxSearchable extension to my own classes so that they can be searched, too. :) The last problem that exists is that $SphinxSearchForm still doesn't show anything, I have to use the code that I posted in my first posting in this topic.

Avatar
mark_s

Community Member, 78 Posts

6 July 2010 at 9:21pm

Hi. That's great :-)

Avatar
Carbon Crayon

Community Member, 598 Posts

16 July 2010 at 5:08am

Hi Mark,

I am getting the same error when trying to perform the search using v0.2 and SS2.4. Running Sphinx/reindex returns 'OK' and running Sphinx/diagnose returns:

NOTICES: - Database type: mysql - Database server: 127.0.0.1 - Database port: 3306 - Database props: aabweb_ukc - Sphinx listening to: /tmp/silverstripe-cache-home-aabweb-public_html-ukc/sphinx/searchd.sock - Sphinx configuration location is /tmp/silverstripe-cache-home-aabweb-public_html-ukc/sphinx - Sphinx binary locations: /usr/local/bin/indexer, /usr/local/bin/searchd, /usr/local/bin/search

and the sphinx.conf looks like this:

source BaseSrc {
   
   type = mysql
   sql_host = localhost
   sql_user = xxxxxxxxx
   sql_pass = xxxxxxxxx
   sql_db = aabweb_ukc
   sql_port = 3306
   
}

index BaseIdx {
   # source = BaseSrc
   # path = /tmp/silverstripe-cache-home-aabweb-public_html-ukc/sphinx/idxs/Base

.....etc.

I had a look in the index files in /tmp/...../sphinx/idxs and they are all blank.....?

I also went through the checklist in your fist post and as far as I can see it's all fine.

Any idea what might be going wrong?

Thanks for your help

Aram

Avatar
Carbon Crayon

Community Member, 598 Posts

17 July 2010 at 11:03pm

Anyone? I am really struggling with getting anything other than the default search working.....All I really need is to be able to include DataObjects managed in model admin to be included in the search but so far no luck......

Has anybody got a better search working in 2.4?

Thanks

Aram

www.ssbits.com - SilverStripe Tutorials, Tips and other bits

Go to Top