Hi Georgina

In the index definition, can you try changing the index reference from 
'DR/account' to 'dr/account', run rake ts:rebuild and see if that helps?

-- 
Pat

On 29 Jan 2014, at 1:32 pm, Georgina Wood <[email protected]> wrote:

> Hi, I keep getting the following error  (ThinkingSphinx::NoIndicesError - see 
> below) when I try to call DR::Accounts.search 'Smith' .
> I have no problems when I do a global search (ThinkingSphinx.search) and have 
> no problems with rake ts:configure, ts:index and ts:start. 
> I also have no problems with calling DR::Accounts.find(:first) using just 
> active record.
> 
> I am using Sinatra (1.3.2)  and thinking-sphinx (3.1.0)
> I'm not sure if the structure I am using is entirely correct. 
> 
> Any feedback would be appreciated.
> 
> 
> 
> rackup -p 4567
> 
> api server started
> Starting Creditors-CR on /api/creditors/CR
> ...
> Starting ClientPortal on /api/clientportal
> Starting Search on /api/search
> All Started
> >> Thin web server (v1.5.1 codename Straight Razor)
> >> Maximum connections set to 1024
> >> Listening on 0.0.0.0:4567, CTRL+C to stop
> ThinkingSphinx::NoIndicesError - ThinkingSphinx::NoIndicesError:
> /H/georgina/.gem/ruby/1.9.1/gems/thinking-sphinx-3.1.0/lib/thinking_sphinx/middlewares/sphinxql.rb:137:in
>  `indices'
> /H/georgina/.gem/ruby/1.9.1/gems/thinking-sphinx-3.1.0/lib/thinking_sphinx/middlewares/sphinxql.rb:25:in
>  `call'
> /H/georgina/.gem/ruby/1.9.1/gems/thinking-sphinx-3.1.0/lib/thinking_sphinx/middlewares/sphinxql.rb:11:in
>  `block in call'
> /H/georgina/.gem/ruby/1.9.1/gems/thinking-sphinx-3.1.0/lib/thinking_sphinx/middlewares/sphinxql.rb:10:in
>  `each'
> /H/georgina/.gem/ruby/1.9.1/gems/thinking-sphinx-3.1.0/lib/thinking_sphinx/middlewares/sphinxql.rb:10:in
>  `call'
> /H/georgina/.gem/ruby/1.9.1/gems/thinking-sphinx-3.1.0/lib/thinking_sphinx/middlewares/stale_id_filter.rb:10:in
>  `call'
> /usr/lib/ruby/gems/1.9.1/gems/middleware-0.1.0/lib/middleware/runner.rb:31:in 
> `call'
> /usr/lib/ruby/gems/1.9.1/gems/middleware-0.1.0/lib/middleware/builder.rb:102:in
>  `call'
> /H/georgina/.gem/ruby/1.9.1/gems/thinking-sphinx-3.1.0/lib/thinking_sphinx/search.rb:67:in
>  `populate'
> /H/georgina/.gem/ruby/1.9.1/gems/thinking-sphinx-3.1.0/lib/thinking_sphinx/search.rb:113:in
>  `method_missing'
> /s/home/georgina/module/api/search.rb:37:in `block in <class:ApiSearch>'
> /usr/lib/ruby/gems/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:1293:in `call'
> /usr/lib/ruby/gems/1.9.1/gems/sinatra-1.3.6/lib/sinatra/base.rb:1293:in 
> `block in compile!'
> ...
> 
> 
> 
> Gemfile:
> 
> source 'http://rubygems.org'
> 
> gem 'mysql2', '~> 0.3.13'
> gem 'sinatra', '~> 1.3.2'
> gem 'sqlite3', '~> 1.3.7'
> gem 'json', '~> 1.6.8'
> 
> # Bundle the extra gems:
> gem 'activerecord', '~> 3.2.14'
> gem 'activerecord-import', '~> 0.3.1'
> gem 'savon', '~> 2.3.0'
> 
> gem 'thinking-sphinx', :require => 'thinking_sphinx/sinatra' 
> gem 'rake'
> 
> Rakefile:
> 
> require 'thinking_sphinx/tasks'
> require 'thinking_sphinx/sinatra'
> 
> task :environment do
>       require File.expand_path('config/environment', File.dirname(__FILE__))
> end
> 
> config/environment.rb:
> 
> require './api_server_lib.rb'                   (active record base, 
> establish_connection)
> require './app/models/DR.rb'
> load 'app/indicies/DR.rb'
> 
> search.rb
> 
> require 'thinking_sphinx/sinatra'
> 
> require './config/environment.rb'
> 
> class ApiSearch < ApiServer
> 
>   addTemplate({ :url => '/api/search/applications?{parameters}',   :options 
> => "GET" })
> 
>   get '/applications' do
>     p 'params: '+params.to_s
> 
>     #street = ThinkingSphinx.search params['keywords']
>     #return street.to_s
> 
>     #p DR::Accounts.find(:first)
> 
>     road = DR::Accounts.search 'road'
>     p road.to_s
> 
>     #ave = ThinkingSphinx.search 'ave'  , :classes => [DR::Accounts]
>     #p ave
>     #'here'
>   end
> 
> 
> Indicies:
> 
> app/indicies/DR.rb:
> 
> module DR 
>   def self.table_name_prefix
>     'dr_'
>   end
> 
>   load 'app/indicies/DR/accounts.rb'
> end
> 
> app/indicies/DR/accounts.rb:
> 
> ThinkingSphinx::Index.define 'DR/accounts', :with => :active_record do
>     indexes debtor_id, :sortable => true
>     indexes first_name
>     
>     indexes surname
>     indexes address_1
>     indexes address_2
>     indexes address_3
>     indexes address_4
> 
>     exclude control account 
>     
>     where "debtor_id NOT RLIKE '^ {7}9'"
> end
> 
> 
> 
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Thinking Sphinx" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/thinking-sphinx.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/thinking-sphinx.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to