搜索引擎 Sphinx 搜索不出某个属性的解决办法

amanda_meng · 2015年08月13日 · 7116 次阅读

Sphinx -------------------------

如下是我的 sphinx 配置文件里面的部分内容:

开始是使用 sql_attr_string = name 因为我希望 sphinx 在搜索出来结果后把 name 返回给我,但是发现搜索全名的适合却搜不出结果。比如 一个商品的全名为 "PEPSI COLA 20OZ",当搜索‘PEPSI COLA’的时候商品可以被搜索出来,搜索‘PEPSI COLA 20OZ’时却没有结果。

查看文档得知

http://sphinxsearch.com/docs/current.html#conf-sql-attr-string

12.1.23. sql_attr_string

String attribute declaration. Multi-value (ie. there may be more than one such attribute declared), optional. Applies to SQL source types (mysql, pgsql, mssql) only. Introduced in version 1.10-beta. String attributes can store arbitrary strings attached to every document. There's a fixed size limit of 4 MB per value. Also, searchd will currently cache all the values in RAM, which is an additional implicit limit. Starting from 2.0.1-beta string attributes can be used for sorting and grouping(ORDER BY, GROUP BY, WITHIN GROUP ORDER BY). Note that attributes declared using sql_attr_string will not be full-text indexed; you can use sql_field_string directive for that.

所以把 sql_attr_string 换成 sql_field_string 问题完美解决,搜索‘PEPSI COLA 20OZ’也出了想要的结果。

暂无回复。
需要 登录 后方可回复, 如果你还没有账号请 注册新账号