I'm using Apache Solr with Solarium client library for PHP.
The problem is special character, a dash (-
).
When I have a dash in my search query, I don't get any matches.
I tried to solve this by using Solarium_Query_Helper::escapeTerm()
. But I don't get any matches again. The dash is being escaped with a backslash \
.
What is the solution for this problem?
I was thinking about escaping all fields when indexing, but that doesn't sound like a good idea.
Here is the part of my 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" />