Error with retrieving excerpts for results from 2nd index on the same model

28 views
Skip to first unread message

Douglas Tan

unread,
Jul 20, 2011, 5:59:57 AM7/20/11
to thinkin...@googlegroups.com
Hi list,

I'm getting the error below when fetching result excerpts from another index defined on a model:

Loading development environment (Rails 2.3.8)
ruby-1.8.7-p334 :001 > r = ThinkingSphinx.search('banner', :index => 'published_with_publication_period')
 => [#<Page id: 25, title: "Prizes", slug: "prizes", breadcrumb: "Prizes", class_name: nil, status_id: 100, parent_id: 4, layout_id: nil, created_at: "2011-07-14 13:57:31", updated_at: "2011-07-20 09:27:38", published_at: "2011-07-13 16:00:00", created_by_id: 2, updated_by_id: 1, virtual: false, lock_version: 8, description: "", keywords: "", position: 5, role_id: nil, published_revision_number: 3, expires_at: nil, protected_from_changes: false, editor_id: nil, reviewer_id: nil, review_revision_number: nil, state_id: 100, delta: true>]
ruby-1.8.7-p334 :002 > r.excerpt_for :title, Page
Riddle::ResponseError: searchd error (status: 1): unknown local index 'published_with_publication_period' in search request
    from /Users/douglas/.rvm/gems/ruby-1.8.7-p334/gems/riddle-1.3.3/lib/riddle/client.rb:668:in `request'
    from /Users/douglas/.rvm/gems/ruby-1.8.7-p334/gems/riddle-1.3.3/lib/riddle/client.rb:406:in `excerpts'
    from /Users/douglas/.rvm/gems/ruby-1.8.7-p334/gems/thinking-sphinx-1.4.6/lib/thinking_sphinx/search.rb:323:in `excerpt_for'
    from (irb):2

My model has 2 indexes defined:

define_index do
  set_property :delta => true, :group_concat_max_len => SphinxSearch.content_length || 8.kilobytes
  set_property :field_weights => { 'title' => 100 }
  indexes title, :sortable => true
  indexes parts.content
  has created_at, updated_at, status_id, virtual
end

base.define_index 'published_with_publication_period' do
  set_property :delta => true, :group_concat_max_len => SphinxSearch.content_length || 8.kilobytes
  set_property :field_weights => { 'title' => 100 }
  indexes title, :sortable => true
  indexes parts.content
  has created_at, updated_at, status_id, virtual

  db_date = "\"#{Time.zone.today.to_s(:db)}\""
  where "((published_at <= #{db_date} AND expires_at > #{db_date}) OR (published_at <= #{db_date} AND expires_at is null) OR (published_at IS NULL AND expires_at > #{db_date}) OR (published_at IS NULL AND expires_at IS NULL))"
end

The error only occurs when I search with the index "published_with_publication_period". I'm working with TS on a Radiant project and I've taken care to make sure that inheritance of my indexed model (Page) doesn't occur until the indexes are defined.

Douglas Tan

unread,
Jul 20, 2011, 9:52:14 PM7/20/11
to thinkin...@googlegroups.com
I decided to workaround the excerpt problem by clearing the sphinx_index_blocks array before creating another index definition. So my new definition is now the first index and the default one. I used this admittedly roundabout solution because the index definitions are actually in 2 different Radiant extensions and I can't seem to find a way to modify indexing parameters of a previously defined block.

Pat Allan

unread,
Jul 21, 2011, 8:01:20 AM7/21/11
to thinkin...@googlegroups.com
Wow, this is not an ideal solution...

Although to be honest, I'm not sure why it's not working in the first place - one thing to try is adding the _core suffix to the index option in your search request.

--
Pat

On 21/07/2011, at 11:52 AM, Douglas Tan wrote:

> I decided to workaround the excerpt problem by clearing the sphinx_index_blocks array before creating another index definition. So my new definition is now the first index and the default one. I used this admittedly roundabout solution because the index definitions are actually in 2 different Radiant extensions and I can't seem to find a way to modify indexing parameters of a previously defined block.
>
>

> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/VDuh8ISh05UJ.
> To post to this group, send email to thinkin...@googlegroups.com.
> To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.

Douglas Tan

unread,
Jul 21, 2011, 9:47:44 AM7/21/11
to thinkin...@googlegroups.com
Thanks Pat, adding the suffix seems to have made the excerpt error go away.
Reply all
Reply to author
Forward
0 new messages