#
# sphinx configuration file for CATS
#

#############################################################################
## data source definition
#############################################################################

source catsdb
{
    type            	= mysql

    # some straightforward parameters for 'mysql' source type
    sql_host            = 192.168.48.4
    sql_port            = 3306  # optional, default is 3306
    sql_db              = cats_dit
    sql_user            = dit_db_user
    sql_pass            = '_dit_db_user_P@$$w0r8123.'

    sql_query_pre       = REPLACE INTO sph_counter SELECT 1, MAX(attachment_id) from attachment
    sql_query           = \
        SELECT attachment_id, title, attachment.site_id AS site_id, UNIX_TIMESTAMP(attachment.date_created) AS date_added, text \
        FROM attachment LEFT JOIN candidate ON data_item_id = candidate_id \
        WHERE resume = 1 AND data_item_type IN(100,500) AND text IS NOT NULL AND text != '' \
        AND attachment_id <= (SELECT max_doc_id FROM sph_counter WHERE counter_id = 1)

    sql_attr_uint	    = site_id
    sql_attr_timestamp	= date_added
    sql_query_post      =
#    sql_query_info      = SELECT * FROM attachment WHERE attachment_id=$id
}

source delta : catsdb
{
    sql_query_pre 		=
    sql_query 			= \
        SELECT attachment_id, title, attachment.site_id AS site_id, UNIX_TIMESTAMP(attachment.date_created) AS date_added, text \
        FROM attachment LEFT JOIN candidate ON data_item_id = candidate_id \
        WHERE resume = 1 AND data_item_type IN(100,500) AND text IS NOT NULL AND text != '' \
        AND attachment_id > (SELECT max_doc_id FROM sph_counter WHERE counter_id = 1)
    
}

#############################################################################
## index definition
#############################################################################

index cats
{
    source          	= catsdb

    # this is path and index file name without extension
    #
    # indexer will append different extensions to this path to
    # generate names for both permanent and temporary index files
    #
    # .tmp* files are temporary and can be safely removed
    # if indexer fails to remove them automatically
    #
    # .sp* files are fulltext index data files. specifically,
    # .spa contains attribute values attached to each document id
    # .spd contains doclists and hitlists
    # .sph contains index header (schema and other settings)
    # .spi contains wordlists
    #
    # MUST be defined
    path        		= /var/lib/sphinx/index/cats

    docinfo     		= extern
    dict				= keywords
    html_strip      	= 0
    html_index_attrs    =
    morphology  		= none
    stopwords   		= /var/lib/sphinx/STOPWORDS
    min_word_len    	= 1
#    charset_type    	= utf-8
}

index catsdelta : cats
{
    source              = delta
    path                = /var/lib/sphinx/index/cats_delta

}

#############################################################################
## indexer settings
#############################################################################

indexer
{
    mem_limit           = 192M
}

#############################################################################
## searchd settings
#############################################################################

searchd
{
    listen          	= 9312
    listen          	= 9306:mysql41
    log             	= /var/lib/sphinx/var/log/searchd.log
    query_log       	= /var/lib/sphinx/var/log/query.log
    read_timeout    	= 5
    max_children    	= 30
    pid_file        	= /var/lib/sphinx/var/run/searchd.pid
    seamless_rotate     = 1
    preopen_indexes     = 1
    unlink_old          = 1
    binlog_path         = /opt/var/data
#    port            	= 9306
#    max_matches     	= 1000
}
