Issue while configuring thinking-sphinx, ThinkingSphinx::NoIndicesError

58 views Asked by At

I'm running a ubuntu server with searchd which is running after it created index.

So basically all works:

indexing index 'pois'...
WARNING: attribute 'id' not found - IGNORING
collected 1760907 docs, 27.4 MB
sorted 3.4 Mhits, 100.0% done
total 1760907 docs, 27438485 bytes
total 2.795 sec, 9813909 bytes/sec, 629822.77 docs/sec
total 1761030 reads, 0.347 sec, 0.1 kb/call avg, 0.0 msec/call avg
total 334 writes, 0.072 sec, 621.5 kb/call avg, 0.2 msec/call avg
ubuntu@stl-back-3:/etc/sphinxsearch$ sudo searchd
Sphinx 2.2.11-id64-release (95ae9a6)
Copyright (c) 2001-2016, Andrew Aksyonoff
Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com)

using config file '/etc/sphinxsearch/sphinx.conf'...
listening on 127.0.0.1:9312
listening on 127.0.0.1:9306
listening on xxx.xxx.xxx.xxx:9396
precaching index 'pois'
precached 1 indexes in 0.037 sec                            

Then I need to user another server for Rails to use this pois index

So I set my config like this:

  enable_star: true
  min_infix_len: 2
  max_matches: 10000
  version: '2.2.11'

  address: xxx.xxx.xxx.xxx
  port: 9396

And yes i double checked with telnet, port is open on xxx.xxx.xxx.xxx:9396

Then I have a simple model like this:

  include ThinkingSphinx::ActiveRecord

  define_index "pois", with: :active_record do
    indexes name
    has latitude, longitude, population, altitude
  end
end

I also tried with this syntax: sphinx_scope(:source => :pois)

But whenever I try to make a search, I have this error sent:

Traceback (most recent call last):
ThinkingSphinx::NoIndicesError (ThinkingSphinx::NoIndicesError)

What do I miss?

thanks a lot

1

There are 1 answers

5
pat On

If you're wanting to use Thinking Sphinx to integrate Sphinx with Rails, then instead of invoking searchd (and indexer and other Sphinx CLI executables) directly, you need to use Thinking Sphinx's rake tasks, such as bundle exec rake ts:index and bundle exec rake ts:rebuild: https://freelancing-gods.com/thinking-sphinx/v5/rake_tasks.html

But also, as noted by @smathy in a comment: the define_index call within a model is a very old syntax, not used since Thinking Sphinx v2 (2013), whereas since v3 the index definitions live in their own files in app/indices: https://freelancing-gods.com/thinking-sphinx/v5/indexing

Thinking Sphinx v2 is for Rails 3.0/3.1 - if you're on a newer version of Rails, then you must use TS v3 or newer (ideally v5.5, which supports Rails 4.2 onwards).