source rt {
    type            = mysql

    sql_host        = localhost
    sql_db          = rt4
    sql_user        = <amended>
    sql_pass        = <amended>

    sql_query_pre   = SET NAMES utf8

    sql_query       = \
        select  A.id, \
                A.Content, \
                TK.Subject as Subject, \
                TK.id as Ticket, \
                TK.Creator as CreatedBy, \
                TK.Queue as Queue, \
                unix_timestamp(convert_tz(TK.Created,'GMT','Europe/Rome')) as Created \
           from Tickets TK, Transactions T, Attachments A \
          where ((T.ObjectId = TK.id) or (T.ObjectId is null)) \
            and A.TransactionId = T.id \
            and T.ObjectType = 'RT::Ticket' \
            and A.ContentType = 'text/plain' \
            and A.Content is not null \
            and TK.Created < concat(year(now()),'-',month(now()),'-01') \
            and TK.Status != 'deleted'

        sql_attr_timestamp      = Created
        sql_attr_uint           = Queue
        sql_attr_uint           = CreatedBy
        sql_attr_uint           = Ticket

    sql_query_info  = SELECT * FROM Attachments WHERE id=$id
}

source rtdelta : rt
{
    sql_query       = \
        select  A.id, \
                A.Content, \
                TK.Subject as Subject, \
                TK.id as Ticket, \
                TK.Creator as CreatedBy, \
                TK.Queue as Queue, \
                unix_timestamp(convert_tz(TK.Created,'GMT','Europe/Rome')) as Created \
           from Tickets TK, Transactions T, Attachments A \
          where ((T.ObjectId = TK.id) or (T.ObjectId is null)) \
            and A.TransactionId = T.id \
            and T.ObjectType = 'RT::Ticket' \
            and A.ContentType = 'text/plain' \
            and A.Content is not null \
            and TK.Created between concat(year(now()),'-',month(now()),'-01') and last_day(now()) \
            and TK.Status != 'deleted'
}


index rt {
    source                  = rt
    path                    = /var/sphinx/index
    docinfo                 = extern
    charset_type            = utf-8
    min_infix_len           = 3
    enable_star             = 1
}

index rtdelta: rt
{
    source                  = rtdelta
    path                    = /var/sphinx/indexdelta
    charset_type            = utf-8
    min_infix_len           = 3
    enable_star             = 1
}

indexer {
    mem_limit               = 256M
}

searchd {
    port                    = 3312
    log                     = /var/sphinx/searchd.log
    query_log               = /var/sphinx/query.log
    read_timeout            = 5
    max_children            = 30
    pid_file                = /var/sphinx/searchd.pid
    max_matches             = 10000
    seamless_rotate         = 1
    preopen_indexes         = 0
    unlink_old              = 1
    workers                 = threads
    binlog_path             = /var/sphinx/
    compat_sphinxql_magics  = 0
}
