Topic: Ultrasphinx

I'm trying to use Ultrasphinx in my latest application (I've always used Ferret, but I thought I tried out a new full-text search engine).  I have sphinx setup, and ultrasphinx in my app, and the default.base configured as such...

#
# Sphinx/Ultrasphinx user-configurable options.
#
# Copy this file to RAILS_ROOT/config/ultrasphinx. You can use individual 
# namespaces if you want (e.g. development.base, production.base, 
# test.base). Note that ERb is also allowed.
#
# This file should not be handed directly to Sphinx. Use the rake task 
#
#   rake ultrasphinx::configure
#
# to generate a parallel default.conf file. This is the file that Sphinx itself will
# use. The Ultrasphinx rake tasks automatically pass the correct file to 
# to Sphinx.
# 
# It is safe to edit .base files by hand. It is not safe to edit the generated 
# .conf files. Do not symlink the .conf file to the .base file; it's wrong.
#

<% path = "/opt/local/var/db/sphinx/" %>

# Indexing options
indexer
{  
  mem_limit = 256M 

  # Ultrasphinx-specific key
  delta = <%= 1.day + 30.minutes %> 
}

# Daemon options
searchd 
{ 
address = 0.0.0.0 
port = 3312 
log = log/searchd.log 
query_log = log/query.log 
read_timeout = 5 
max_children = 300 
pid_file = log/searchd.pid 
max_matches = 100000 
}

# Client options
client
{
  # Name of the Aspell dictionary (two letters max)
  dictionary_name = ap
  
  # How your application connects to the search daemon (not necessarily the same as above)
  server_host = localhost
  server_port = 3313
}

# Individual SQL source options
source
{  
  sql_ranged_throttle = 0  
  sql_range_step = 5000   
  sql_query_post =
  strip_html = 1
}

# Index building options
index
{  
  path = sphinx
  docinfo = extern # Just leave this alone
  morphology = stem_en
  stopwords = # <%= path %>/ap-stopwords.txt
  min_word_len = 1

  # HTML-specific options
  html_strip = 0
  html_index_attrs =
  
  # Enable these if you need wildcard searching. They will slow down indexing significantly.
  #   min_infix_len = 1    
  #   enable_star = 1 

  # # URL search options
  # # add " @, /, :," before " a-z," in the charset_table and uncomment prefix_fields
  # to seach URL and email addresses
  # prefix_fields = url, domain
    
  charset_type = utf-8 # or sbcs (Single Byte Character Set)
  charset_table = 0..9, A..Z->a..z, -, _, ., &, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F,U+C5->U+E5, U+E5, U+C4->U+E4, U+E4, U+D6->U+F6, U+F6, U+16B, U+0c1->a, U+0c4->a, U+0c9->e, U+0cd->i, U+0d3->o, U+0d4->o, U+0da->u, U+0dd->y, U+0e1->a, U+0e4->a, U+0e9->e, U+0ed->i, U+0f3->o, U+0f4->o, U+0fa->u, U+0fd->y, U+104->U+105, U+105, U+106->U+107, U+10c->c, U+10d->c, U+10e->d, U+10f->d, U+116->U+117, U+117, U+118->U+119, U+11a->e, U+11b->e, U+12E->U+12F, U+12F, U+139->l, U+13a->l, U+13d->l, U+13e->l, U+141->U+142, U+142, U+143->U+144, U+144,U+147->n, U+148->n, U+154->r, U+155->r, U+158->r, U+159->r, U+15A->U+15B, U+15B, U+160->s, U+160->U+161, U+161->s, U+164->t, U+165->t, U+16A->U+16B, U+16B, U+16e->u, U+16f->u, U+172->U+173, U+173, U+179->U+17A, U+17A, U+17B->U+17C, U+17C, U+17d->z, U+17e->z,
}

Everything starts up fine when  I run rake ultrasphinx:bootstrap, but if I try to script/console and query the index, I get connection errors.

>> @search = Ultrasphinx::Search.new(:query => 'biomedical')
=> #<Ultrasphinx::Search:0x1875234 @facets={}, @response={}, @results=[], @options={"indexes"=>"main", "class_names"=>[], "sort_by"=>nil, "parsed_query"=>"biomedical", "sort_mode"=>"relevance", "filters"=>{}, "weights"=>{}, "per_page"=>20, "query"=>"biomedical", "page"=>1, "facets"=>[], "location"=>{"units"=>"radians", "long_attribute_name"=>"lng", "lat_attribute_name"=>"lat"}}, @subtotals={}>
>> @search.run
Errno::ECONNREFUSED: Connection refused - connect(2)
	from /Users/zack/Dropbox/website/vendor/plugins/ultrasphinx/lib/../vendor/riddle/lib/riddle/client.rb:387:in `initialize'
	from /Users/zack/Dropbox/website/vendor/plugins/ultrasphinx/lib/../vendor/riddle/lib/riddle/client.rb:387:in `new'
	from /Users/zack/Dropbox/website/vendor/plugins/ultrasphinx/lib/../vendor/riddle/lib/riddle/client.rb:387:in `connect'
	from /Users/zack/Dropbox/website/vendor/plugins/ultrasphinx/lib/../vendor/riddle/lib/riddle/client.rb:415:in `request'
	from /Users/zack/Dropbox/website/vendor/plugins/ultrasphinx/lib/../vendor/riddle/lib/riddle/client.rb:170:in `run'
	from /Users/zack/Dropbox/website/vendor/plugins/ultrasphinx/lib/../vendor/riddle/lib/riddle/client.rb:277:in `query'
	from /Users/zack/Dropbox/website/vendor/plugins/ultrasphinx/lib/ultrasphinx/search.rb:341:in `run'
	from /Users/zack/Dropbox/website/vendor/plugins/ultrasphinx/lib/ultrasphinx/search/internals.rb:352:in `perform_action_with_retries'
	from /Users/zack/Dropbox/website/vendor/plugins/ultrasphinx/lib/ultrasphinx/search.rb:340:in `run'
	from (irb):4

I've queried Google all day and have had no luck.  I downloaded / compiled all of this today.  This is on Rails 2.1.1 and Sphinx 0.9.8-rc2 on Leopard 10.5.6.  Has anybody seen / solved this before?

**EDIT** I solved it.  Here's a situation where a little proofreading on my part would have really helped.  In my config file, I have searchd (the ultrasphinx daemon) running on port 3312, and the clients trying to connect to it with port 3313.  A simple edit of my config file, and re-running the rake task has everything working now.


Thanks,
Zack

Last edited by zreed20 (2009-03-12 11:35:34)

But they that wait upon the Lord shall renew their strength