2014-02-01 01:55



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')
                  ->addSearchTerm('name', $queryString)
                  ->addSearchTerm('surname', $queryString);

$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!

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • duanke1984 duanke1984 7年前

    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">
        <tokenizer class="solr.StandardTokenizerFactory"/>
        <filter class="solr.LowerCaseFilterFactory"/>
    点赞 评论 复制链接分享