0

I've set up Thinking Sphinx gem https://github.com/pat/thinking-sphinx and I'm trying to get it work with globalize https://github.com/globalize/globalize gem.

I have a model named Content that has :name, :body ,:summary attributes and also has

translates :name, :body, :summary, :fallbacks_for_empty_translations => true

for translations. I've created a content_index that has

ThinkingSphinx::Index.define :content, :with => :active_record do

  indexes translations.summary, :sortable => true
  indexes translations.body , :sortable => true

  where "content_translations.locale = 'my_locale'"  



end

When I do rake ts:index or rake ts:rebuild I get

Generating configuration to rails_app_path/config/development.sphinx.conf Sphinx 2.1.8-id64-release (rel21-r4675) Copyright (c) 2001-2014, Andrew Aksyonoff Copyright (c) 2008-2014, Sphinx Technologies Inc (http://sphinxsearch.com)

using config file 'rails_app_path/config/development.sphinx.conf'... indexing index 'content_core'...

collected 43 docs, 0.0 MB

sorted 0.0 Mhits, 100.0% done

total 43 docs, 3266 bytes

total 0.005 sec, 616808 bytes/sec, 8120.86 docs/sec

skipping non-plain index 'content'...

total 3 reads, 0.000 sec, 1.3 kb/call avg, 0.0 msec/call avg

total 10 writes, 0.000 sec, 1.5 kb/call avg, 0.0 msec/call avg

rotating indices: successfully sent SIGHUP to searchd (pid=8282).

So when I get to rails console (rails c) and try something like

Content.search "something"

I get empty results.

2.1.2 :050 > Content.search("something")

Sphinx Query (0.6ms) SELECT * FROM content_core WHERE MATCH('something') AND sphinx_deleted = 0 LIMIT 0, 20

Sphinx Found 0 results

=> []

Does skipping non-plain index 'content'... line in ts:rebuild task has anything to do with it?

Alexphys
  • 408
  • 4
  • 11
  • The 'skipping non-plain index' messages are completely normal (non-plain indexes can't be indexed). The 'something' you're searching for - is that in the translation columns? Or does Content itself have the same columns (given the fallbacks setting) and that's where the value is? – pat Jul 28 '14 at 09:26
  • Thanks for your time. "something" is a word included in a text column of a translations record (the last record I created on testing purposes). It may be or maybe not included in the Content itself, in the examples I have tried it wasn't. – Alexphys Jul 28 '14 at 09:34
  • And 'something' is the actual phrase you're testing with? Or is it something else? In particular, is it something outside the standard ASCII characters? And with that in mind, which versions of Sphinx and Thinking Sphinx are you using? Older releases of both weren't quite UTF friendly by default. – pat Jul 28 '14 at 12:33
  • No as a matter of fact its greek characters , with exact phrase being "και" (means 'and' in greek so its use in text bodies is very often). But I don't think thats the case , besides greek characters being in UTF-8 encoding ,I also tested french (latin) characters as well. What I've forgotten to mention , is that the texts come in html_tags (because I commit them with ckeditor) but I've included in my config/thinking_sphinx.yml 'html_strip: true'. Do you think it could relate with it somehow? – Alexphys Jul 28 '14 at 12:51
  • Perhaps it's the html stripping, but html_strip should handle that fine... which versions of Sphinx and Thinking Sphinx are you using? – pat Jul 28 '14 at 16:05
  • My sphinx version is 2.1.9 and thinking sphinx 3.1.1. – Alexphys Jul 29 '14 at 08:02
  • Right, both of those should allow for UTF by default. Can you fire up a mysql console that connects to Sphinx (`mysql --host 127.0.0.1 --port 9306`) and run `SELECT * FROM content_core` to see what gets returned? – pat Jul 29 '14 at 08:57
  • @pat Well seems that I have missed something very basic here. After running mysql --host 127.0.0.1 --port 9306 I got ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111) – Alexphys Jul 29 '14 at 16:59
  • Are you using Sphinx on a custom port? Is this testing happening locally, or on a remote machine? – pat Jul 29 '14 at 18:53

0 Answers0