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

indexer
{
    mem_limit = 4096M
}

source base
{
    type            = mysql

    sql_host        = localhost
    sql_user        = root
    sql_pass        = Tenposs@123
    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
}



#### Front End Source
source areas:base
{
    sql_query          = SELECT id, name, slug, description, logo, title, sub_title, link, show_top, show_search, \
                         parent_id, position, is_activated, UNIX_TIMESTAMP(created_at) AS created_at \
                         FROM areas where is_deleted = 0

    sql_field_string   = name
    sql_field_string   = slug
    sql_attr_string    = description
    sql_attr_string    = logo
    sql_attr_string    = title
    sql_attr_string    = sub_title
    sql_attr_string    = link
    sql_attr_uint      = show_top
    sql_attr_uint      = show_search
    sql_attr_uint      = parent_id
    sql_attr_uint      = position
    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 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
}

source medias:base
{
    sql_query          = \
                        select id, name, slug, file, file_type, extension, size, \
                        width, height, important, alt, description, type, parent_id, \
                        UNIX_TIMESTAMP(created_at) AS created_at, UNIX_TIMESTAMP(updated_at) AS updated_at \
                        from files \
                        where is_deleted = 0

    sql_field_string   = name
    sql_field_string   = file
    sql_field_string   = slug
    sql_attr_string    = file_type
    sql_attr_string    = extension
    sql_attr_string    = size
    sql_attr_string    = alt
    sql_attr_string    = description
    sql_attr_uint      = type
    sql_attr_uint      = width
    sql_attr_uint      = height
    sql_attr_uint      = important
    sql_attr_uint      = parent_id
    sql_attr_uint      = created_at
    sql_attr_uint      = updated_at
}

source seoes:base
{
    sql_query          = \
                        select id, uri, title, robots, keywords, description, image, note, type, post_id, is_amp, \
                        UNIX_TIMESTAMP(created_at) AS created_at, UNIX_TIMESTAMP(updated_at) AS updated_at \
                        from seo_metas

    sql_field_string   = uri
    sql_field_string   = title
    sql_attr_string    = robots
    sql_attr_string    = keywords
    sql_attr_string    = description
    sql_attr_string    = image
    sql_attr_string    = note
    sql_attr_string    = type
    sql_attr_uint      = post_id
    sql_attr_uint      = is_amp
    sql_attr_uint      = created_at
    sql_attr_uint      = updated_at
}

source sliders:base
{
    sql_query          = \
                        select id, name, slug, position, size, autoplay, autoplaySpeed, speed, slidesToShow, slidesToScroll, \
                        infinite, fade, dots, arrows, pauseOnHover, pauseOnFocus, is_activated, \
                        UNIX_TIMESTAMP(created_at) AS created_at, UNIX_TIMESTAMP(updated_at) AS updated_at \
                        from sliders \
                        where is_deleted = 0

    sql_field_string   = name
    sql_field_string   = slug
    sql_field_string   = position
    sql_attr_string    = size
    sql_attr_uint      = autoplay
    sql_attr_uint      = autoplaySpeed
    sql_attr_uint      = speed
    sql_attr_uint      = slidesToShow
    sql_attr_uint      = slidesToScroll
    sql_attr_uint      = infinite
    sql_attr_uint      = fade
    sql_attr_uint      = dots
    sql_attr_uint      = arrows
    sql_attr_uint      = pauseOnHover
    sql_attr_uint      = pauseOnFocus
    sql_attr_uint      = is_activated
    sql_attr_uint      = created_at
    sql_attr_uint      = updated_at
}

source slider_details:base
{
    sql_query          = \
                        select id, slider_id, name, title, description, is_line, image, origin_image, \
                        link, type_link, color, stroke, border, is_shadow, is_blur, overlay_opacity, \
                        overlay_size, overlay_color, sub_image, width, height, \
                        UNIX_TIMESTAMP(created_at) AS created_at, UNIX_TIMESTAMP(updated_at) AS updated_at \
                        from slider_details

    sql_attr_uint        = slider_id
    sql_field_string     = name
    sql_field_string     = title
    sql_attr_string      = description
    sql_attr_uint        = is_line
    sql_attr_string      = image
    sql_attr_string      = origin_image
    sql_attr_string      = link
    sql_attr_string      = type_link
    sql_attr_string      = color
    sql_attr_string      = stroke
    sql_attr_string      = border
    sql_attr_uint        = is_shadow
    sql_attr_uint        = is_blur
    sql_attr_string      = overlay_opacity
    sql_attr_string      = overlay_size
    sql_attr_string      = overlay_color
    sql_attr_string      = sub_image
    sql_attr_string      = width
    sql_attr_string      = height
    sql_attr_uint        = created_at
    sql_attr_uint        = updated_at
}

source methods:base
{
    sql_query          = \
                        select id, name, slug, description, top_name, logo, show_top, \
                        UNIX_TIMESTAMP(created_at) AS created_at, UNIX_TIMESTAMP(updated_at) AS updated_at \
                        from fortune_methods where is_deleted = 0 and is_activated = 1

    sql_field_string   = name
    sql_field_string   = slug
    sql_attr_string    = description
    sql_attr_string    = top_name
    sql_attr_string    = logo
    sql_attr_uint      = show_top
    sql_attr_uint      = created_at
    sql_attr_uint      = updated_at
}

source areas_sta:base
{
    sql_query          = \
                        select areas.id, areas.name, areas.slug, areas.logo, s1.shop_total, s2.teller_total \
                        from areas \
                        left join (select areas.id, areas.slug, count(shops.id) as shop_total from areas left join shops on (areas.id = shops.area_id and shops.is_deleted = 0 and shops.is_activated = 1) where areas.is_deleted = 0 and areas.is_activated = 1 group by areas.id) s1 on areas.id = s1.id \
                        left join (select shops.area_id, count(fortune_tellers.id) as teller_total from shops left join fortune_tellers on (shops.id = fortune_tellers.shop_id and fortune_tellers.is_deleted = 0 and fortune_tellers.is_activated = 1) where shops.is_deleted = 0 and shops.is_activated = 1 group by shops.area_id) s2 on areas.id = s2.area_id \
                        where areas.show_top = 1 order by areas.position, areas.id

    sql_field_string   = name
    sql_field_string   = slug
    sql_attr_string    = logo
    sql_attr_uint      = shop_total
    sql_attr_uint      = teller_total
}


index areas_index
{
    source            = areas
    path              = /var/www/html/uramori.jp/storage/sphinx/areas_index
    min_word_len      = 1
    min_prefix_len    = 0
}

index shops_front_index
{
    source            = shops_front
    path              = /var/www/html/uramori.jp/storage/sphinx/shops_front_index
    min_word_len      = 1
    min_prefix_len    = 0
}

index fortunes_index
{
    source            = fortunes
    path              = /var/www/html/uramori.jp/storage/sphinx/fortunes_index
    min_word_len      = 1
    min_prefix_len    = 0
}

index keywords_index
{
    source            = keywords
    path              = /var/www/html/uramori.jp/storage/sphinx/keywords_index
    min_word_len      = 1
    min_prefix_len    = 0
}

index medias_index
{
    source            = medias
    path              = /var/www/html/uramori.jp/storage/sphinx/medias_index
    min_word_len      = 1
    min_prefix_len    = 0
}

index seoes_index
{
    source            = seoes
    path              = /var/www/html/uramori.jp/storage/sphinx/seoes_index
    min_word_len      = 1
    min_prefix_len    = 0
}

index sliders_index
{
    source            = sliders
    path              = /var/www/html/uramori.jp/storage/sphinx/sliders_index
    min_word_len      = 1
    min_prefix_len    = 0
}

index slider_details_index
{
    source            = slider_details
    path              = /var/www/html/uramori.jp/storage/sphinx/slider_details_index
    min_word_len      = 1
    min_prefix_len    = 0
}

index methods_index
{
    source            = methods
    path              = /var/www/html/uramori.jp/storage/sphinx/methods_index
    min_word_len      = 1
    min_prefix_len    = 0
}

index areas_sta_index
{
    source            = areas_sta
    path              = /var/www/html/uramori.jp/storage/sphinx/areas_sta_index
    min_word_len      = 1
    min_prefix_len    = 0
}






#### Back End Source
source admin_shops:base
{
    sql_query          = SELECT shops.id, shops.name, shops.slug, shops.description, areas.name as area_name, shops.`order` as order_list, shops.is_activated \
                         FROM shops \
                         inner join areas on shops.area_id = areas.id \
                         WHERE shops.is_deleted = 0

    sql_field_string   = name
    sql_attr_string    = slug
    sql_attr_string    = description
    sql_attr_string    = area_name
    sql_attr_uint      = order_list
    sql_attr_string    = is_activated
}

source admin_fortune_tellers:base
{
    sql_query          = \
                        select fortune_tellers.id, fortune_tellers.name, fortune_tellers.display_name, fortune_tellers.slug, fortune_tellers.shop_id, s.name as shop_name \
                        from fortune_tellers \
                        left join shops s on fortune_tellers.shop_id = s.id \
                        where fortune_tellers.is_deleted = 0

    sql_field_string   = name
    sql_field_string   = shop_name
    sql_attr_string    = display_name
    sql_attr_string    = slug
    sql_attr_uint      = shop_id
}


index admin_shops_index
{
    source            = admin_shops
    path              = /var/www/html/uramori.jp/storage/sphinx/admin_shops_index
    min_word_len      = 1
    min_prefix_len    = 0
}

index admin_fortune_tellers_index
{
    source            = admin_fortune_tellers
    path              = /var/www/html/uramori.jp/storage/sphinx/admin_fortune_tellers_index
    min_word_len      = 1
    min_prefix_len    = 0
}




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

