开发者

Sphinx sort problem?

开发者 https://www.devze.com 2023-02-28 05:58 出处:网络
i am using 1.10 sphinx. source tags { type= mysql sql_host= localhost sql_user= abc sql_pass= 123456 sql_db= company

i am using 1.10 sphinx.

source tags
{
    type                            = mysql
    sql_host                        = localhost
    sql_user                        = abc
    sql_pass                        = 123456
    sql_db                          = company
    sql_sock                        =  /var/lib/mysql/mysql.sock
    sql_port                        = 3306

     sql_query_pre = SET NAMES utf8
     sql_query_range        = SELECT 1,max(id) FROM companies

sql_query                       = \
        SELECT id,name FROM companies;
;
      sql_attr_str2ordinal = name  

}

this is sorted by name but i am retriving data. the result set is [name] => 954 ...... like this coming .

sql_attr_str2ordinal = name before use this i am using sql_field_string = name that name is retrive but not so开发者_开发百科rt by name. what is the solution for this?


sql_attr_str2ordinal :

Does not stores the value only stores the sort order (ordinal) after indexing. so you can not the value from it.

sql_field_string :

full-text field but lacks sorting (since its not an attribute).

sql_attr_string :

lacks full-text index.

So what I would do is :

source tags
{
    type                            = mysql
    sql_host                        = localhost
    sql_user                        = abc
    sql_pass                        = 123456
    sql_db                          = company
    sql_sock                        =  /var/lib/mysql/mysql.sock
    sql_port                        = 3306

     sql_query_pre = SET NAMES utf8
     sql_query_range        = SELECT 1,max(id) FROM companies

     sql_query                       = \
        SELECT id,name as name_ordinal, name as name FROM companies;
     sql_attr_str2ordinal = name_ordinal
     sql_field_string = name


}

Then sort by name_ordinal and query with name

0

精彩评论

暂无评论...
验证码 换一张
取 消