Search code examples
mysqlfieldsphinxauto-increment

Sphinx create attribute for mysql primary key auto increment id


I am trying to create sphinx index for same copy for my mysql table but there i got a error for my auto increment id. So i can't create a same field name of auto increment id.

Error:

WARNING: attribute 'u_g_id' not found - IGNORING

Here is my config..

###############################
    ## Sphinx configuration file ##
    ###############################
    # Source For Assamese Male Profiles
    source usergallerysrc
    {
            type                            = mysql
            sql_host                        = localhost
            sql_user                        = test
            sql_pass                        = test
            sql_db                          = test
            sql_query                       = SELECT u_g_id,u_g_u_id,u_g_type,u_g_path,u_g_time from user_gallery where u_g_status='1'

            sql_attr_bigint         = u_g_id        
            sql_attr_bigint                 = u_g_u_id
        sql_attr_uint                   = u_g_type
        sql_attr_timestamp              = u_g_time
            sql_field_string                = u_g_path

    }

    ######################
    ## index definition ##
    ######################
    # gallery index
    index usergalleryindex
    {
            source                  = usergallerysrc
            path                    = /usr/local/sphinx/var/data/usergalleryindex/usergalleryindex
            docinfo                 = extern
            mlock                   = 0
            morphology              = none
            min_word_len            = 1
            charset_type            = sbcs
            html_strip              = 1
            html_remove_elements    = style, script
            enable_star             = 1
            min_infix_len           = 3
    }

Any one can help me... Thanks in advance...


Solution

  • The first column from the sql_query result is used as the document_id ALWAYS. It can't be defined as an attribute.

    So u_g_id cant be found because its already been used.

    If you want to use a column for document_id and an attribute (although I can't think why you would) will just have to duplicate it in the query.