Hi Greg
Just to make it easier for me to debug - can you let me know either which
commit you're using, or upgrade to the latest?
Can't spot anything odd in your code, so it does sound like a TS bug. Although
one thing to note - you don't need :as => :app_id for your attribute, as that's
what the column is called. Not that what you're doing will break anything,
though :)
Cheers
--
Pat
On 13/08/2010, at 5:47 AM, gjb wrote:
> Hello,
>
> I have been trying to run a search through ts and have been running up
> against a very vexing error.
>
> We have a documents table, where each document has a certain number of
> pages belonging to it. We want to search and return results from the
> documents table, but we want to index the text of all the pages
> belonging to the document.
>
> Here is the define_index code in our Document model:
>
> has_many :pages,
> :order => 'page_number ASC'
>
> define_index do
> indexes pages.text, :as => :doc_text
> has app_id, :as => :app_id
> where "status = 4"
> end
>
> And here is where we make the search() call:
>
> word_matched_docs = Document.search("*#{word}*", :per_page =>
> 1000, :max_matches => 1048576, :with => {:app_id => self.id})
>
> Every time I make this call, I am getting the following stack trace
> out of the plugin:
>
> Fatal error sent to user during search: NoMethodError -- You have a
> nil object when you didn't expect it!
> You might have expected an instance of Array.
> The error occurred while evaluating nil.last
> /mnt/app/releases/20100809194919/web/vendor/plugins/thinking-sphinx/
> lib/thinking_sphinx/active_record.rb:101:in `sphinx_index_options'
> /mnt/app/releases/20100809194919/web/vendor/plugins/thinking-sphinx/
> lib/thinking_sphinx/search.rb:490:in `client_from_options'
> /mnt/app/releases/20100809194919/web/vendor/plugins/thinking-sphinx/
> lib/thinking_sphinx/search.rb:450:in `search_results'
> /mnt/app/releases/20100809194919/web/vendor/plugins/thinking-sphinx/
> lib/thinking_sphinx/search.rb:364:in `search'
> /mnt/app/releases/20100809194919/web/vendor/plugins/thinking-sphinx/
> lib/thinking_sphinx/search.rb:388:in `call'
> /mnt/app/releases/20100809194919/web/vendor/plugins/thinking-sphinx/
> lib/thinking_sphinx/search.rb:388:in `retry_search_on_stale_index'
> /mnt/app/releases/20100809194919/web/vendor/plugins/thinking-sphinx/
> lib/thinking_sphinx/search.rb:363:in `search'
> /mnt/app/releases/20100809194919/web/vendor/plugins/thinking-sphinx/
> lib/thinking_sphinx/active_record/search.rb:29:in `search'
> /mnt/app/releases/20100809194919/web/app/models/app.rb:98:in
> `sphinx_search'
> /mnt/app/releases/20100809194919/web/app/models/app.rb:93:in `each'
> /mnt/app/releases/20100809194919/web/app/models/app.rb:93:in
> `sphinx_search'
>
> Something seems to definitely be wrong within Thinking Sphinx itself
> and not the sphinx index because if I run the "search" command through
> the command line I get the results I expect:
>
> search -f app_id 12 -c /current/web/config/qa.sphinx.conf business -l
> 10
>
> We're using version 0.9.8.1 of sphinx and Thinking Sphinx 1.3.17 (a
> commit or so after) installed as a plugin.
>
> Can anyone tell me what I might be doing wrong? Is it something to do
> with the association between the Document and Page models?
>
> Thanks for any assistance.
>
> Greg
>
> --
> You received this message because you are subscribed to the Google Groups
> "Thinking Sphinx" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/thinking-sphinx?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/thinking-sphinx?hl=en.