Just to be sure - do you want delta indexing to occur when the description has 
changed? Or to *not* run when the description has changed?

Your custom delta subclass seems to have mixed behaviour.

On 26/07/2013, at 10:45 AM, [email protected] wrote:

> 1、thinking-sphinx 3.0.4
> 2、ruby  1.9
> 3、sphinx 2.0.8
> 
> then config the delta index
> 1、class AddColumeToSnippets < ActiveRecord::Migration
>   def change
>       add_column :snippets, :delta , :boolean, :default => true, :null => 
> false
>       add_column :users, :delta , :boolean, :default => true, :null => false
>       add_column :projects, :delta , :boolean, :default => true, :null => 
> false
>       add_column :organizations, :delta , :boolean, :default => true, :null 
> => false
>   end
> end
> 
> 2、class SnippetDeltas < ThinkingSphinx::Deltas::DefaultDelta
>   def toggle(instance)
>     super unless instance.description_changed?
>   end
> 
>   def toggled?(instance)
>     return false unless instance.description_changed?
> 
>     super
>   end
> end
> 
> ThinkingSphinx::Index.define :snippet, :with => :active_record, :delta => 
> SnippetDeltas do
>   indexes name, description
>   indexes public_flag, :sortable => true
>   indexes snippet_files.file_name, :as => :related_file_names
>   indexes snippet_files.content, :as => :related_file_content
>   indexes language.name, :as => :language_name
> 
>   has created_at, star_count, fork_count, language_tag_id
> end
> 
> 3、rake ts:index ,    the output is:
> indexing index 'snippet_core'...
> collected 11 docs, 0.0 MB
> sorted 0.0 Mhits, 100.0% done
> total 11 docs, 187 bytes
> total 0.005 sec, 36782 bytes/sec, 2163.65 docs/sec
> indexing index 'snippet_delta'...
> collected 0 docs, 0.0 MB
> total 0 docs, 0 bytes
> total 0.001 sec, 0 bytes/sec, 0.00 docs/sec
> total 12 reads, 0.000 sec, 0.1 kb/call avg, 0.0 msec/call avg
> total 42 writes, 0.000 sec, 0.1 kb/call avg, 0.0 msec/call avg
> rotating indices: successfully sent SIGHUP to searchd (pid=21585).
> 
> and the development.sphinx.conf's config is:
> source snippet_core_0
> {
>   type = mysql
>   sql_host = localhost
>   sql_user = root
>   sql_pass =
>   sql_db = gitlabhq_development
>   sql_query_pre = UPDATE `snippets` SET `delta` = 0 WHERE `delta` = 1
>   sql_query_pre = SET NAMES utf8
>   sql_query = SELECT SQL_NO_CACHE `snippets`.`id` * 8 + 3 AS `id`, 'Snippet' 
> AS `sphinx_internal_class_name`, `snippets`.`name` AS `name`, 
> `snippets`.`description` AS `description`, `snippets`.`public_flag` AS 
> `public_flag`, GROUP_CONCAT(snippet_files.`file_name` SEPARATOR ' ') AS 
> `related_file_names`, GROUP_CONCAT(snippet_files.`content` SEPARATOR ' ') AS 
> `related_file_content`, sys_tags.`name` AS `language_name`, `snippets`.`id` 
> AS `sphinx_internal_id`, 'Snippet' AS `sphinx_internal_class`, 0 AS 
> `sphinx_deleted`, UNIX_TIMESTAMP(`snippets`.`created_at`) AS `created_at`, 
> `snippets`.`star_count` AS `star_count`, `snippets`.`fork_count` AS 
> `fork_count`, `snippets`.`language_tag_id` AS `language_tag_id` FROM 
> `snippets` LEFT OUTER JOIN `snippet_files` ON `snippet_files`.`snippet_id` = 
> `snippets`.`id` LEFT OUTER JOIN `sys_tags` ON `sys_tags`.`id` = 
> `snippets`.`language_tag_id` WHERE (`snippets`.`delta` = 0 AND 
> `snippets`.`id` BETWEEN $start AND $end) GROUP BY `snippets`.`id`, 
> `snippets`.`name`, `snippets`.`description`, `snippets`.`public_flag`, 
> sys_tags.`name`, `snippets`.`id`, `snippets`.`created_at`, 
> `snippets`.`star_count`, `snippets`.`fork_count`, 
> `snippets`.`language_tag_id` ORDER BY NULL
>   sql_query_range = SELECT IFNULL(MIN(`snippets`.`id`), 1), 
> IFNULL(MAX(`snippets`.`id`), 1) FROM `snippets`  WHERE (`snippets`.`delta` = 
> 0)
>   sql_attr_uint = sphinx_internal_id
>   sql_attr_uint = sphinx_deleted
>   sql_attr_uint = star_count
>   sql_attr_uint = fork_count
>   sql_attr_uint = language_tag_id
>   sql_attr_timestamp = created_at
>   sql_attr_string = sphinx_internal_class
>   sql_field_string = public_flag
>   sql_query_info = SELECT `snippets`.* FROM `snippets`  WHERE 
> (`snippets`.`id` = ($id - 3) / 8)
> }
> 
> index snippet_core
> {
>   type = plain
>   path = /home/git/labhub/db/sphinx/development/snippet_core
>   docinfo = extern
>   charset_type = utf-8
>   source = snippet_core_0
> }
> source snippet_delta_0
> {
>   type = mysql
>   sql_host = localhost
>   sql_user = root
>   sql_pass =
>   sql_db = gitlabhq_development
>   sql_query_pre = SET NAMES utf8
>   sql_query = SELECT SQL_NO_CACHE `snippets`.`id` * 8 + 3 AS `id`, 'Snippet' 
> AS `sphinx_internal_class_name`, `snippets`.`name` AS `name`, 
> `snippets`.`description` AS `description`, `snippets`.`public_flag` AS 
> `public_flag`, GROUP_CONCAT(snippet_files.`file_name` SEPARATOR ' ') AS 
> `related_file_names`, GROUP_CONCAT(snippet_files.`content` SEPARATOR ' ') AS 
> `related_file_content`, sys_tags.`name` AS `language_name`, `snippets`.`id` 
> AS `sphinx_internal_id`, 'Snippet' AS `sphinx_internal_class`, 0 AS 
> `sphinx_deleted`, UNIX_TIMESTAMP(`snippets`.`created_at`) AS `created_at`, 
> `snippets`.`star_count` AS `star_count`, `snippets`.`fork_count` AS 
> `fork_count`, `snippets`.`language_tag_id` AS `language_tag_id` FROM 
> `snippets` LEFT OUTER JOIN `snippet_files` ON `snippet_files`.`snippet_id` = 
> `snippets`.`id` LEFT OUTER JOIN `sys_tags` ON `sys_tags`.`id` = 
> `snippets`.`language_tag_id` WHERE (`snippets`.`delta` = 1 AND 
> `snippets`.`id` BETWEEN $start AND $end) GROUP BY `snippets`.`id`, 
> `snippets`.`name`, `snippets`.`description`, `snippets`.`public_flag`, 
> sys_tags.`name`, `snippets`.`id`, `snippets`.`created_at`, 
> `snippets`.`star_count`, `snippets`.`fork_count`, 
> `snippets`.`language_tag_id` ORDER BY NULL
>   sql_query_range = SELECT IFNULL(MIN(`snippets`.`id`), 1), 
> IFNULL(MAX(`snippets`.`id`), 1) FROM `snippets`  WHERE (`snippets`.`delta` = 
> 1)
>   sql_attr_uint = sphinx_internal_id
>   sql_attr_uint = sphinx_deleted
>   sql_attr_uint = star_count
>   sql_attr_uint = fork_count
>   sql_attr_uint = language_tag_id
>   sql_attr_timestamp = created_at
>   sql_attr_string = sphinx_internal_class
>   sql_field_string = public_flag
>   sql_query_info = SELECT `snippets`.* FROM `snippets`  WHERE 
> (`snippets`.`id` = ($id - 3) / 8)
> }
> 
> index snippet_delta
> {
>   type = plain
>   path = /home/git/labhub/db/sphinx/development/snippet_delta
>   docinfo = extern
>   charset_type = utf-8
>   source = snippet_delta_0
> }
> 
> 4、when i insert a record into DB,and the delta colum's value is 1,but it 
> never changed until I mannually exec rake ts:index
> 
> Then next question is:when I update a record, Why the delta column don't 
> change to 1?
> 
> 
> I want to know does it run automatically? 
> Thanks!
> 
> 
> 
> -- 
> 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