Reputation: 1565
I've been googling all day to try and figure out how to set a query to be not case sensitive. I'm currently using Florian Semm's SolrBundle at this github page. I thought it would be as simple as saying $query->setCaseSensitive(false);
or something similair, but apparently not. Any ideas? I'm using Solr4.1.6 and Symfony 2.4.1 if that makes any difference.
This is what I have so far...
$solrQuery = $this->get('solr.client.default')
->createQuery('MyBundle:User')
->addSearchTerm('name', $queryString)
->addSearchTerm('surname', $queryString);
$solrQuery->setUseWildcard(true);
$entities = $solrQuery->getResult();
This obviously returns correctly, but only if the case of the query is correct. For example, searching for "Thom" returns the entity containing "Thomas", but "thom" does not.
Thanks for any help!
Upvotes: 0
Views: 341
Reputation: 603
You might want to look the solr Schema as there could be analyzers configured in there. Specifically if LowerCaseFilterFactory is configured in your schema it will convert the text terms to lowercase while the content is being indexed, same is possible in query time. Example below is what you might want to look for.
<fieldtype name="text" class="solr.TextField">
<analyzer>
......
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldtype>
Upvotes: 2