#### sql_field_ => save and create index, sql_attr_ => only save not create index
#### string => string, uint => integer. float => float, timestamp => timestamp

indexer
{
    mem_limit = 512M
}

source base
{
    type            = mysql

    sql_host        = localhost
    sql_user        = root
    sql_pass        = abc1234$
    sql_db          = qole
    sql_port        = 3306
    sql_sock        = /var/run/mysqld/mysqld.sock

    sql_query_pre  = SET NAMES utf8
    sql_query_pre  = SET CHARACTER SET utf8
    sql_query_pre  = SET CHARACTER_SET_RESULTS=utf8
}

source areas:base
{
    sql_query          = SELECT id, name, slug, description FROM areas

    sql_field_string   = name
    sql_attr_string    = slug
    sql_attr_string    = description
}

source shops:base
{
    sql_query          = SELECT id, area_id, name, slug, description, logo, `order` AS `order_list`, is_activated, UNIX_TIMESTAMP(created_at) AS created_at FROM shops WHERE is_deleted = 0

    sql_field_string   = name
    sql_attr_uint      = area_id
    sql_attr_string    = slug
    sql_attr_string    = description
    sql_attr_string    = logo
    sql_attr_uint      = order_list
    sql_attr_uint      = is_activated
    sql_attr_uint      = created_at
}

source shops_front:base
{
    sql_query          = \
                        SELECT shops.id, shops.name, shops.slug, shops.description, shops.logo, shops.address, shops.station, shops.order AS order_list, shops.show_search, shops.area_id, a.slug as area_slug, a.parent_id as area_parent_id \
                        FROM shops \
                        join areas a on shops.area_id = a.id \
                        WHERE shops.is_deleted = 0 and shops.is_activated = 1 \

    sql_field_string   = name
    sql_field_string   = slug
    sql_field_string   = description
    sql_attr_uint      = area_id
    sql_field_string   = area_slug
    sql_field_string   = area_parent_id
    sql_attr_string    = logo
    sql_attr_string    = address
    sql_attr_string    = station
    sql_attr_uint      = order_list
    sql_attr_uint      = show_search
}

source fortunes:base
{
    sql_query          = \
                        select fortune_tellers.id, fortune_tellers.name, fortune_tellers.display_name, fortune_tellers.gender, \
                                fortune_tellers.slug, fortune_tellers.number, fortune_tellers.avatar, fortune_tellers.ref_name_id, fortune_tellers.desc_1_full, fortune_tellers.show_top, \
                                fortune_tellers.shop_id, s.name as shop_name, s.area_id as area_id, a.name as area_name, a.slug as area_slug, UNIX_TIMESTAMP(fortune_tellers.created_at) AS created_at \
                         from fortune_tellers \
                         left join shops s on fortune_tellers.shop_id = s.id \
                         join areas a on s.area_id = a.id \
                         where fortune_tellers.is_deleted = 0 \
                         and fortune_tellers.is_activated = 1

    sql_field_string   = name
    sql_field_string   = display_name
    sql_field_string   = slug
    sql_field_string   = shop_id
    sql_field_string   = shop_name
    sql_field_string   = area_id
    sql_field_string   = area_name
    sql_field_string   = area_slug
    sql_field_string   = ref_name_id
    sql_attr_uint      = gender
    sql_attr_uint      = number
    sql_attr_uint      = show_top
    sql_attr_string    = avatar
    sql_attr_string    = desc_1_full
    sql_attr_uint      = created_at
}

source methods:base
{
    sql_query          = \
                        select fortune_method_details.id, fortune_method_details.fortune_method_id, fortune_method_details.fortune_teller_id, fm.name, fm.slug, fm.logo, fm.top_name \
                        from fortune_method_details \
                        join fortune_methods fm on fortune_method_details.fortune_method_id = fm.id \
                        where fm.is_deleted = 0 and fm.is_activated = 1

    sql_field_string   = name
    sql_field_string   = slug
    sql_attr_uint      = fortune_method_id
    sql_attr_uint      = fortune_teller_id
    sql_attr_string    = logo
    sql_attr_string    = top_name
}

source keywords:base
{
    sql_query          = \
                        select keyword_details.id, keyword_details.ref_id, keyword_details.type, k.name \
                        from keyword_details \
                        join keywords k on keyword_details.keyword_id = k.id \
                        where k.is_deleted = 0 and k.is_activated = 1

    sql_field_string   = type
    sql_field_string   = name
    sql_attr_uint      = ref_id
}


index areas_index
{
    source            = areas
    path              = /var/www/qole/storage/sphinx/areas_index
    min_word_len      = 1
    min_prefix_len    = 0
}

index shops_front_index
{
    source            = shops_front
    path              = /var/www/qole/storage/sphinx/shops_front_index
    min_word_len      = 1
    min_prefix_len    = 0
}

index fortunes_index
{
    source            = fortunes
    path              = /var/www/qole/storage/sphinx/fortunes_index
    min_word_len      = 1
    min_prefix_len    = 0
}

index methods_index
{
    source            = methods
    path              = /var/www/qole/storage/sphinx/methods_index
    min_word_len      = 1
    min_prefix_len    = 0
}

index keywords_index
{
    source            = keywords
    path              = /var/www/qole/storage/sphinx/keywords_index
    min_word_len      = 1
    min_prefix_len    = 0
}

index shops_index
{
    source            = shops
    path              = /var/www/qole/storage/sphinx/shops_index
    min_word_len      = 1
    min_prefix_len    = 0
}

searchd
{
    listen          = 9312
    listen          = 9306:mysql41
    log             = /var/www/qole/storage/sphinx/logs/searchd.log
    query_log       = /var/www/qole/storage/sphinx/logs/query.log
    read_timeout    = 5
    max_children    = 30
    pid_file        = /var/www/qole/storage/sphinx/searchd.pid
    seamless_rotate = 1
    preopen_indexes = 1
    unlink_old      = 1
    workers         = threads
    binlog_path     = /var/www/qole/storage/sphinx/binlog
}
