<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>amanda_meng (孟凡玲)</title>
    <link>https://ruby-china.org/amanda_meng</link>
    <description></description>
    <language>en-us</language>
    <item>
      <title>Sphinx 搜索不出某个属性的解决办法</title>
      <description>&lt;p&gt;Sphinx -------------------------&lt;/p&gt;
&lt;h4 id="如下是我的sphinx配置文件里面的部分内容："&gt;如下是我的 sphinx 配置文件里面的部分内容：&lt;/h4&gt;
&lt;p&gt;&lt;img src="https://l.ruby-china.com/photo/2015/d1bfbe002a53916954dc9c1264da7081.png" title="" alt=""&gt;&lt;/p&gt;

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

&lt;p&gt;查看文档得知&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="http://sphinxsearch.com/docs/current.html#conf-sql-attr-string" rel="nofollow" target="_blank" title=""&gt;http://sphinxsearch.com/docs/current.html#conf-sql-attr-string&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="12.1.23. sql_attr_string"&gt;&lt;strong&gt;12.1.23. sql_attr_string&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;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 &lt;strong&gt;not&lt;/strong&gt; be full-text indexed; you can use sql_field_string directive for that.&lt;/p&gt;

&lt;p&gt;所以把 sql_attr_string 换成 sql_field_string  问题完美解决，搜索‘PEPSI COLA 20OZ’也出了想要的结果。&lt;/p&gt;</description>
      <author>amanda_meng</author>
      <pubDate>Thu, 13 Aug 2015 14:16:00 +0800</pubDate>
      <link>https://ruby-china.org/topics/26908</link>
      <guid>https://ruby-china.org/topics/26908</guid>
    </item>
  </channel>
</rss>
