对于一般查询而言 , 分词和存储都是必要的 . 比如 CPU 类型 ”Intel 酷睿 2 双核 P7570”, 拆分成 ”Intel”,” 酷睿 ”,”P7570” 这样一些关键字并分别索引 , 可能提供更好的搜索体验 . 但是如果将 CPU 作为
Facet 字段 , 最好不进行分词 . 这样就造成了矛盾 , 解决方法为 , 将 CPU 字段设置为不分词不存储 ,
然后建立另外一个字段为它的 COPY, 对这个 COPY 的字段进行分词和存储 .
schema.xml
<types>
<fieldType name="string" class="solr.StrField" omitNorms="true"/>
<fieldType name="tokened" class="solr.TextField" >
<analyzer>
……
</analyzer>
</fieldType>
……
</types>
<fields>
<field name=”cpu” type=”string” indexed=”true” stored=”false”/>
<field name=”cpuCopy” type=” tokened” indexed=”true” stored=”true”/>
……
</fields>
<copyField source="cpu" dest="cpuCopy"/>