初学者:关于狮身人面像& SphinxQL

时间:2015-12-02 06:00:42

标签: mysql sphinx sphinxql

我已经设法配置,编制索引并运行sphinx,现在我正在使用SphinxQL来检索一些数据。

问题是,当我尝试查询时,结果只给出了“id”。 这让我感到困惑。 我在mySQL上的数据由以下列组成

GENDB_ID //auto increment
GENDB_PDO //product origin, string
GENDB_FPN //family part number, string
GENDB_PN //part number, string

问题:

  1. 为什么Sphinx在我的“GENDB_ID”上设置别名“id”?

  2. 当我尝试指定我想在查询中获得哪些列时,我得到“列不存在”错误。如何查询某些列?

  3. rt是什么?我的rt索引总是被跳过。

  4. 这是我的sphinx配置:

    #
    # Minimal Sphinx configuration sample (clean, simple, functional)
    #
    
    source src1
    {
        type            = mysql
    
        sql_host        = localhost
        sql_user        = root
        sql_pass        = 1234
        sql_db          = sample
        sql_port        = 3306  # optional, default is 3306
    
        sql_query       = \
            SELECT * \
            FROM general
    }
    
    
    index test1
    {
        source          = src1
        path            = C:/Sphinx/data/test1
        min_infix_len   = 3
    }
    
    
    index testrt //This one doesnt work I don't know why.
    {
        type            = rt
        rt_mem_limit        = 128M
    
        path            = C:/Sphinx/data/testrt
        rt_field    = GENDB_PDO
    }
    
    
    indexer
    {
        mem_limit       = 500M
    }
    
    
    searchd
    {
        listen          = 9312
        listen          = 9306:mysql41
        log             = C:/Sphinx/log/searchd.log
        query_log       = C:/Sphinx/log/query.log
        read_timeout        = 5
        max_children        = 30
        pid_file        = C:/Sphinx/log/searchd.pid
        seamless_rotate     = 1
        preopen_indexes     = 1
        unlink_old      = 1
        workers         = 2
        binlog_path     = C:/Sphinx/data
        max_matches     = 10000000
    
    }
    

1 个答案:

答案 0 :(得分:1)

  1. Sphinx总是会调用document-id' id'。它不是真正的属性,document-id很关键,因此可以单独处理索引上的任何字段或属性。

  2. 您只能检索'属性。只有属性存储在索引中,并且可以按原样使用。 FIELD被标记化并编入索引,因此匹配全文查询。但原始文本未存储。 (从sql_query中检索到的列会自动变为FIELDS,除非您将它们专门配置为ATTRIBUTES - 除了第一列,如上所述是特殊的)

    http://sphinxsearch.com/docs/current.html#attributes

    http://sphinxsearch.com/docs/current.html#extended-syntax

    您可以选择将它们添加为ATTRIBUTES(可能使用sql_field_string,因此属性和字段都可以)。或者接受你无法从sphinx获取它们,并将原始数据返回到你的mysql数据库。

    (对于第二部分,查询某些FIELDS,请参阅' @'语法:http://sphinxsearch.com/docs/current.html#rt-indexes

  3. {{3}}实时索引。一种非常不同类型的索引。

相关问题