【发布时间】:2012-10-11 23:39:21
【问题描述】:
我正在使用带有Solarium PHP 客户端库的 Apache Solr。
问题是特殊字符,破折号 (-)。
当我的搜索查询中有破折号时,我没有得到任何匹配项。
我尝试使用Solarium_Query_Helper::escapeTerm() 来解决这个问题。但我再也没有得到任何匹配。破折号用反斜杠 \ 转义。
这个问题的解决方法是什么?
我正在考虑在索引时转义所有字段,但这听起来不是一个好主意。
这是我schema.xml的一部分:
<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
...
<fields>
...
<field name="myfield" type="text_general" indexed="true" stored="true" />
</fields>
...
<defaultSearchField>text</defaultSearchField>
<copyField source="myfield" dest="text" />
【问题讨论】:
标签: php solr search-engine solarium