As the title said, I always want to know how does the sphinx works,how does it realized that the data has updated and how does it konw which rows what has updated?espacily the last two questions.
sphinx can't guess when data changes, you need to tell him to check for new data with cronjob for instance. Let me show you an example :
Let's say you use sphinx to index users, every day, you will have a cronjob that will reindex all data from users from scratch (which means index is destroyed and entirely recreated), and then, every 5 minutes, you will have another cronjob that will index new data only (delta).
So in your users table, you need to have a column to know the last time it was updated, let's call it updated_at.
Your delta_index will then check for users that have been updated since last check.
source user
{
...
sql_query_pre = REPLACE INTO sph_counter SELECT 'user', @max_stamp:=UNIX_TIMESTAMP(MAX(updated_at)) FROM users
sql_query = SELECT user_id, email FROM users WHERE updated_at <= FROM_UNIXTIME(@max_stamp)
...
}
source user_delta : user
{
...
sql_query = SELECT user_id, email FROM users WHERE updated_at >= (SELECT FROM_UNIXTIME(MAX_ID) FROM sph_counter WHERE INDEX_NAME = 'user')
...
}
Does it sound clear to you ?