Hi Mike

The reason for the message in the logs is that Thinking Sphinx/Sphinx
only knows the ids of your search results, and needs to load the
actual objects to return - hence why it talks to the database as well.

As for post_desc - this isn't available as a method anywhere (on the
search collection or search results) - the alias you've given that
column is only for Sphinx, not Ruby. So you can use it when searching:

  Post.search :conditions => {:post_desc => 'foo'}

But if you want the value of post_desc, you will need to access it as
description:

  post = Post.search('foo').first
  post ? post.description : 'No Post'

Hope this clarifies things. If you have any more questions, feel free
to ask on the Thinking Sphinx Google Group (I only spotted your posts
here via some noisy twitter bots):
http://groups.google.com/group/thinking-sphinx

Cheers

--
Pat

On Aug 2, 11:51 pm, Mike Disuza <[email protected]> wrote:
> Hi,
> I am implementing the "sphinx" search using "Thinking Sphinx" search.
> I have done everything configured.
> I have added the index fields in my model like this
> "
>  define_index do
>     indexes :name,:sortable => true
>     indexes description
>     has created_at, updated_at
>   end
> "
> My sphinx configuration file is as
> "
> source post_core_0
> {
>   type = mysql
>   sql_host = localhost
>   sql_user = root
>   sql_pass =
>   sql_db = development
>   sql_sock = /var/lib/mysql/mysql.sock
>   sql_query_pre = SET NAMES utf8
>   sql_query_pre = SET TIME_ZONE = '+0:00'
>   sql_query = SELECT SQL_NO_CACHE `posts`.`id` * 1 + 0 AS `id` ,
> `posts`.`name` AS `name`, `posts`.`description` AS `description`,
> `posts`.`id` AS `sphinx_internal_id`, 1921285768 AS `class_crc`, 0 AS
> `sphinx_deleted`, IFNULL(`posts`.`name`, '') AS `name_sort`,
> UNIX_TIMESTAMP(`posts`.`created_at`) AS `created_at`,
> UNIX_TIMESTAMP(`posts`.`updated_at`) AS `updated_at` FROM `posts`
> WHERE `posts`.`id` >= $start AND `posts`.`id` <= $end AND deleted = 0
> GROUP BY `posts`.`id`  ORDER BY NULL
>   sql_query_range = SELECT IFNULL(MIN(`id`), 1), IFNULL(MAX(`id`), 1)
> FROM `posts`
>   sql_attr_uint = sphinx_internal_id
>   sql_attr_uint = class_crc
>   sql_attr_timestamp = created_at
>   sql_attr_timestamp = updated_at
>   sql_attr_str2ordinal = name_sort
>   sql_query_info = SELECT * FROM `posts` WHERE `id` = (($id - 0) / 1)
>
> }"
>
> The searching works well but I am seeing in the log that it is firing a
> queri like " SELECT * FROM `posts` WHERE `id` = (1,2)"
>
> Is my configuration right?
>
> Also, if I am doing indexing like " indexes description, :as=>
> :post_desc" and if I try to access it like this:-
> "search=ThinkingSphinx.search "test"
> puts search.post_desc
> "
> Giving me an error that "post_desc" is undefined.
>
> Can anyone tell me wwhat is happening?
>
> Thanks,
> Mike
> --
> Posted viahttp://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" 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/rubyonrails-talk?hl=en.

Reply via email to